mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
feat(CDN): Support emoji size (#9787)
* feat(CDN): support emoji size * refactor: try to warn in all environments * feat: add prefix * refactor: better feedback message --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,9 @@ import {
|
||||
type ImageSize,
|
||||
type StickerExtension,
|
||||
} from './utils/constants.js';
|
||||
import { deprecationWarning } from './utils/utils.js';
|
||||
|
||||
let deprecationEmittedForEmoji = false;
|
||||
|
||||
/**
|
||||
* The options used for image URLs
|
||||
@@ -158,10 +161,38 @@ export class CDN {
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param extension - The extension of the emoji
|
||||
* @param options - Optional options for the emoji
|
||||
*/
|
||||
public emoji(emojiId: string, extension?: ImageExtension): string {
|
||||
return this.makeURL(`/emojis/${emojiId}`, { extension });
|
||||
public emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param extension - The extension of the emoji
|
||||
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
||||
public emoji(emojiId: string, extension?: ImageExtension): string;
|
||||
|
||||
public emoji(emojiId: string, options?: ImageExtension | Readonly<BaseImageURLOptions>): string {
|
||||
let resolvedOptions;
|
||||
|
||||
if (typeof options === 'string') {
|
||||
if (!deprecationEmittedForEmoji) {
|
||||
deprecationWarning(
|
||||
'Passing a string for the second parameter of CDN#emoji() is deprecated. Use an object instead.',
|
||||
);
|
||||
|
||||
deprecationEmittedForEmoji = true;
|
||||
}
|
||||
|
||||
resolvedOptions = { extension: options };
|
||||
} else {
|
||||
resolvedOptions = options;
|
||||
}
|
||||
|
||||
return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user