diff --git a/packages/core/src/api/sticker.ts b/packages/core/src/api/sticker.ts index 66e7383b1a20d..937c78c185494 100644 --- a/packages/core/src/api/sticker.ts +++ b/packages/core/src/api/sticker.ts @@ -4,7 +4,8 @@ import type { RequestData, REST } from '@discordjs/rest'; import { Routes, type RESTGetAPIStickerResult, - type RESTGetNitroStickerPacksResult, + // @ts-expect-error discord-api-types + type RESTGetStickerPacksResult, type Snowflake, } from 'discord-api-types/v10'; @@ -17,8 +18,20 @@ export class StickersAPI { * @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs} * @param options - The options for fetching the sticker packs */ - public async getNitroStickers({ signal }: Pick = {}) { - return this.rest.get(Routes.nitroStickerPacks(), { signal }) as Promise; + public async getStickers({ signal }: Pick = {}) { + // @ts-expect-error discord-api-types + return this.rest.get(Routes.stickerPacks(), { signal }) as Promise; + } + + /** + * Fetches all of the nitro sticker packs + * + * @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs} + * @param options - The options for fetching the sticker packs + * @deprecated Use {@link getStickers} instead. + */ + public async getNitroStickers(options: Pick = {}) { + return this.getStickers(options); } /** diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js index 80719e864786e..b6d02f738a760 100644 --- a/packages/discord.js/src/client/Client.js +++ b/packages/discord.js/src/client/Client.js @@ -31,6 +31,8 @@ const PermissionsBitField = require('../util/PermissionsBitField'); const Status = require('../util/Status'); const Sweepers = require('../util/Sweepers'); +let deprecationEmittedForPremiumStickerPacks = false; + /** * The main hub for interacting with the Discord API, and the starting point for any bot. * @extends {BaseClient} @@ -358,18 +360,36 @@ class Client extends BaseClient { } /** - * Obtains the list of sticker packs available to Nitro subscribers from Discord. + * Obtains the list of available sticker packs. * @returns {Promise>} * @example - * client.fetchPremiumStickerPacks() + * client.fetchStickerPacks() * .then(packs => console.log(`Available sticker packs are: ${packs.map(pack => pack.name).join(', ')}`)) * .catch(console.error); */ - async fetchPremiumStickerPacks() { - const data = await this.rest.get(Routes.nitroStickerPacks()); + async fetchStickerPacks() { + const data = await this.rest.get(Routes.stickerPacks()); return new Collection(data.sticker_packs.map(p => [p.id, new StickerPack(this, p)])); } + /** + * Obtains the list of available sticker packs. + * @returns {Promise>} + * @deprecated Use {@link Client#fetchStickerPacks} instead. + */ + fetchPremiumStickerPacks() { + if (!deprecationEmittedForPremiumStickerPacks) { + process.emitWarning( + 'The Client#fetchPremiumStickerPacks() method is deprecated. Use Client#fetchStickerPacks() instead.', + 'DeprecationWarning', + ); + + deprecationEmittedForPremiumStickerPacks = true; + } + + return this.fetchStickerPacks(); + } + /** * Obtains a guild preview from Discord, available for all guilds the bot is in and all Discoverable guilds. * @param {GuildResolvable} guild The guild to fetch the preview for diff --git a/packages/discord.js/src/structures/Sticker.js b/packages/discord.js/src/structures/Sticker.js index b0f2ef6cb7497..4789c44558899 100644 --- a/packages/discord.js/src/structures/Sticker.js +++ b/packages/discord.js/src/structures/Sticker.js @@ -179,11 +179,11 @@ class Sticker extends Base { } /** - * Fetches the pack this sticker is part of from Discord, if this is a Nitro sticker. - * @returns {Promise} + * Fetches the pack belonging to this sticker. + * @returns {Promise} The sticker pack or `null` if this sticker does not belong to one. */ async fetchPack() { - return (this.packId && (await this.client.fetchPremiumStickerPacks()).get(this.packId)) ?? null; + return (this.packId && (await this.client.fetchStickerPacks()).get(this.packId)) ?? null; } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index fda9b4c0860df..0b7e793fc64d4 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -975,7 +975,9 @@ export class Client extends BaseClient { public fetchGuildTemplate(template: GuildTemplateResolvable): Promise; public fetchVoiceRegions(): Promise>; public fetchSticker(id: Snowflake): Promise; - public fetchPremiumStickerPacks(): Promise>; + public fetchStickerPacks(): Promise>; + /** @deprecated Use {@link fetchStickerPacks} instead. */ + public fetchPremiumStickerPacks(): ReturnType; public fetchWebhook(id: Snowflake, token?: string): Promise; public fetchGuildWidget(guild: GuildResolvable): Promise; public generateInvite(options?: InviteGenerationOptions): string;