|
8 | 8 | type ImageSize,
|
9 | 9 | type StickerExtension,
|
10 | 10 | } from './utils/constants.js';
|
| 11 | +import { deprecationWarning } from './utils/utils.js'; |
| 12 | + |
| 13 | +let deprecationEmittedForEmoji = false; |
11 | 14 |
|
12 | 15 | /**
|
13 | 16 | * The options used for image URLs
|
@@ -154,14 +157,42 @@ export class CDN {
|
154 | 157 | return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
|
155 | 158 | }
|
156 | 159 |
|
| 160 | + /** |
| 161 | + * Generates an emoji's URL for an emoji. |
| 162 | + * |
| 163 | + * @param emojiId - The emoji id |
| 164 | + * @param options - Optional options for the emoji |
| 165 | + */ |
| 166 | + public emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string; |
| 167 | + |
157 | 168 | /**
|
158 | 169 | * Generates an emoji's URL for an emoji.
|
159 | 170 | *
|
160 | 171 | * @param emojiId - The emoji id
|
161 | 172 | * @param extension - The extension of the emoji
|
| 173 | + * @deprecated This overload is deprecated. Pass an object containing the extension instead. |
162 | 174 | */
|
163 |
| - public emoji(emojiId: string, extension?: ImageExtension): string { |
164 |
| - return this.makeURL(`/emojis/${emojiId}`, { extension }); |
| 175 | + // eslint-disable-next-line @typescript-eslint/unified-signatures |
| 176 | + public emoji(emojiId: string, extension?: ImageExtension): string; |
| 177 | + |
| 178 | + public emoji(emojiId: string, options?: ImageExtension | Readonly<BaseImageURLOptions>): string { |
| 179 | + let resolvedOptions; |
| 180 | + |
| 181 | + if (typeof options === 'string') { |
| 182 | + if (!deprecationEmittedForEmoji) { |
| 183 | + deprecationWarning( |
| 184 | + 'Passing a string for the second parameter of CDN#emoji() is deprecated. Use an object instead.', |
| 185 | + ); |
| 186 | + |
| 187 | + deprecationEmittedForEmoji = true; |
| 188 | + } |
| 189 | + |
| 190 | + resolvedOptions = { extension: options }; |
| 191 | + } else { |
| 192 | + resolvedOptions = options; |
| 193 | + } |
| 194 | + |
| 195 | + return this.makeURL(`/emojis/${emojiId}`, resolvedOptions); |
165 | 196 | }
|
166 | 197 |
|
167 | 198 | /**
|
|
0 commit comments