Skip to content

Commit

Permalink
feat: getNitroStickerPacks() -> getStickerPacks() (#109)
Browse files Browse the repository at this point in the history
* feat: getNitroStickerPacks() -> getStickerPacks()

Sticker packs that used to be Nitro-only are free now - this slipped under the radar.

Ref: discord/discord-api-docs#6265

* fix typos

* reword the deprecation message along with reasoning
  • Loading branch information
TTtie committed Sep 13, 2023
1 parent 448f40b commit 9c4a2b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,7 @@ declare namespace Dysnomia {
getMessage(channelID: string, messageID: string): Promise<Message>;
getMessageReaction(channelID: string, messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
getMessages(channelID: string, options?: GetMessagesOptions): Promise<Message[]>;
/** @deprecated */
getNitroStickerPacks(): Promise<{ sticker_packs: StickerPack[] }>;
getOAuthApplication(): Promise<OAuthApplicationInfo>;
getPins(channelID: string): Promise<Message[]>;
Expand All @@ -2739,6 +2740,7 @@ declare namespace Dysnomia {
getRoleConnectionMetadata(): Promise<ApplicationRoleConnectionMetadata[]>;
getSelf(): Promise<ExtendedUser>;
getStageInstance(channelID: string): Promise<StageInstance>;
getStickerPacks(): Promise<{ sticker_packs: StickerPack[] }>;
getThreadMember(channelID: string, memberID: string, options: GetThreadMemberOptions): Promise<ThreadMember>;
getThreadMembers(channelID: string, options: GetThreadMembersOptions): Promise<ThreadMember[]>;
getVoiceRegions(guildID?: string): Promise<VoiceRegion[]>;
Expand Down
16 changes: 13 additions & 3 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const UnavailableGuild = require("./structures/UnavailableGuild");
const User = require("./structures/User");
const VoiceConnectionManager = require("./voice/VoiceConnectionManager");
const AutoModerationRule = require("./structures/AutoModerationRule");
const emitDeprecation = require("./util/emitDeprecation");

let EventEmitter;
try {
Expand Down Expand Up @@ -2489,11 +2490,12 @@ class Client extends EventEmitter {
}

/**
* Get the list of sticker packs available to Nitro subscribers
* @returns {Promise<Object>} An object whichs contains a value which contains an array of sticker packs
* [DEPRECATED] Get the list of sticker packs available to Nitro subscribers
* @returns {Promise<Object>} An object which contains a value which contains an array of sticker packs
*/
getNitroStickerPacks() {
return this.requestHandler.request("GET", Endpoints.STICKER_PACKS, true);
emitDeprecation("NITRO_STICKER_PACKS");
return this.getStickerPacks();
}

/**
Expand Down Expand Up @@ -2747,6 +2749,14 @@ class Client extends EventEmitter {
return this.requestHandler.request("GET", Endpoints.STAGE_INSTANCE(channelID), true).then((instance) => new StageInstance(instance, this));
}

/**
* Get the list of available sticker packs
* @returns {Promise<Object>} An object which contains a value which contains an array of sticker packs
*/
getStickerPacks() {
return this.requestHandler.request("GET", Endpoints.STICKER_PACKS, true);
}

/**
* Gets a thread member object for a specified user
* @arg {String} channelID The ID of the thread channel
Expand Down
1 change: 1 addition & 0 deletions lib/util/emitDeprecation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const warningMessages = {
NITRO_STICKER_PACKS: "Client#getNitroStickerPacks is deprecated as built-in sticker packs are free for everyone. Please use Client#getStickerPacks instead."
};
const unknownCodeMessage = "You have triggered a deprecated behavior whose warning was implemented improperly. Please report this issue.";

Expand Down

0 comments on commit 9c4a2b2

Please sign in to comment.