Skip to content

Commit e02a59b

Browse files
refactor: Stickers are free (no more "premium" packs) (#9791)
refactor: stickers are free Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 32d614c commit e02a59b

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

packages/core/src/api/sticker.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,32 @@ import type { RequestData, REST } from '@discordjs/rest';
44
import {
55
Routes,
66
type RESTGetAPIStickerResult,
7-
type RESTGetNitroStickerPacksResult,
7+
type RESTGetStickerPacksResult,
88
type Snowflake,
99
} from 'discord-api-types/v10';
1010

1111
export class StickersAPI {
1212
public constructor(private readonly rest: REST) {}
1313

1414
/**
15-
* Fetches all of the nitro sticker packs
15+
* Fetches all of the sticker packs
1616
*
17-
* @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs}
17+
* @see {@link https://discord.com/developers/docs/resources/sticker#list-sticker-packs}
1818
* @param options - The options for fetching the sticker packs
1919
*/
20-
public async getNitroStickers({ signal }: Pick<RequestData, 'signal'> = {}) {
21-
return this.rest.get(Routes.nitroStickerPacks(), { signal }) as Promise<RESTGetNitroStickerPacksResult>;
20+
public async getStickers({ signal }: Pick<RequestData, 'signal'> = {}) {
21+
return this.rest.get(Routes.stickerPacks(), { signal }) as Promise<RESTGetStickerPacksResult>;
22+
}
23+
24+
/**
25+
* Fetches all of the sticker packs
26+
*
27+
* @see {@link https://discord.com/developers/docs/resources/sticker#list-sticker-packs}
28+
* @param options - The options for fetching the sticker packs
29+
* @deprecated Use {@link getStickers} instead.
30+
*/
31+
public async getNitroStickers(options: Pick<RequestData, 'signal'> = {}) {
32+
return this.getStickers(options);
2233
}
2334

2435
/**

packages/discord.js/src/client/Client.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const PermissionsBitField = require('../util/PermissionsBitField');
3131
const Status = require('../util/Status');
3232
const Sweepers = require('../util/Sweepers');
3333

34+
let deprecationEmittedForPremiumStickerPacks = false;
35+
3436
/**
3537
* The main hub for interacting with the Discord API, and the starting point for any bot.
3638
* @extends {BaseClient}
@@ -358,18 +360,36 @@ class Client extends BaseClient {
358360
}
359361

360362
/**
361-
* Obtains the list of sticker packs available to Nitro subscribers from Discord.
363+
* Obtains the list of available sticker packs.
362364
* @returns {Promise<Collection<Snowflake, StickerPack>>}
363365
* @example
364-
* client.fetchPremiumStickerPacks()
366+
* client.fetchStickerPacks()
365367
* .then(packs => console.log(`Available sticker packs are: ${packs.map(pack => pack.name).join(', ')}`))
366368
* .catch(console.error);
367369
*/
368-
async fetchPremiumStickerPacks() {
369-
const data = await this.rest.get(Routes.nitroStickerPacks());
370+
async fetchStickerPacks() {
371+
const data = await this.rest.get(Routes.stickerPacks());
370372
return new Collection(data.sticker_packs.map(p => [p.id, new StickerPack(this, p)]));
371373
}
372374

375+
/**
376+
* Obtains the list of available sticker packs.
377+
* @returns {Promise<Collection<Snowflake, StickerPack>>}
378+
* @deprecated Use {@link Client#fetchStickerPacks} instead.
379+
*/
380+
fetchPremiumStickerPacks() {
381+
if (!deprecationEmittedForPremiumStickerPacks) {
382+
process.emitWarning(
383+
'The Client#fetchPremiumStickerPacks() method is deprecated. Use Client#fetchStickerPacks() instead.',
384+
'DeprecationWarning',
385+
);
386+
387+
deprecationEmittedForPremiumStickerPacks = true;
388+
}
389+
390+
return this.fetchStickerPacks();
391+
}
392+
373393
/**
374394
* Obtains a guild preview from Discord, available for all guilds the bot is in and all Discoverable guilds.
375395
* @param {GuildResolvable} guild The guild to fetch the preview for

packages/discord.js/src/structures/Sticker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ class Sticker extends Base {
179179
}
180180

181181
/**
182-
* Fetches the pack this sticker is part of from Discord, if this is a Nitro sticker.
183-
* @returns {Promise<?StickerPack>}
182+
* Fetches the pack that contains this sticker.
183+
* @returns {Promise<?StickerPack>} The sticker pack or `null` if this sticker does not belong to one.
184184
*/
185185
async fetchPack() {
186-
return (this.packId && (await this.client.fetchPremiumStickerPacks()).get(this.packId)) ?? null;
186+
return (this.packId && (await this.client.fetchStickerPacks()).get(this.packId)) ?? null;
187187
}
188188

189189
/**

packages/discord.js/typings/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,9 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
979979
public fetchGuildTemplate(template: GuildTemplateResolvable): Promise<GuildTemplate>;
980980
public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
981981
public fetchSticker(id: Snowflake): Promise<Sticker>;
982-
public fetchPremiumStickerPacks(): Promise<Collection<Snowflake, StickerPack>>;
982+
public fetchStickerPacks(): Promise<Collection<Snowflake, StickerPack>>;
983+
/** @deprecated Use {@link fetchStickerPacks} instead. */
984+
public fetchPremiumStickerPacks(): ReturnType<Client['fetchStickerPacks']>;
983985
public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>;
984986
public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>;
985987
public generateInvite(options?: InviteGenerationOptions): string;

0 commit comments

Comments
 (0)