mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor(Emoji)!: make imageURL() change extension dynamically (#10613)
BREAKING CHANGE: Image URLs of emojis now automatically return GIF or static extensions. BREAKING CHANGE: `CDN#emoji()` now has an `animated` required parameter.
This commit is contained in:
@@ -50,12 +50,28 @@ test('discoverySplash default', () => {
|
||||
expect(cdn.discoverySplash(id, hash)).toEqual(`${baseCDN}/discovery-splashes/${id}/${hash}.webp`);
|
||||
});
|
||||
|
||||
test('emoji default', () => {
|
||||
expect(cdn.emoji(id)).toEqual(`${baseCDN}/emojis/${id}.webp`);
|
||||
test('emoji static', () => {
|
||||
expect(cdn.emoji(id, false)).toEqual(`${baseCDN}/emojis/${id}.webp`);
|
||||
});
|
||||
|
||||
test('emoji gif', () => {
|
||||
expect(cdn.emoji(id, { extension: 'gif' })).toEqual(`${baseCDN}/emojis/${id}.gif`);
|
||||
test('emoji static with JPG extension', () => {
|
||||
expect(cdn.emoji(id, false, { extension: 'jpg' })).toEqual(`${baseCDN}/emojis/${id}.jpg`);
|
||||
});
|
||||
|
||||
test('emoji static with JPG extension with force static', () => {
|
||||
expect(cdn.emoji(id, false, { extension: 'jpg', forceStatic: true })).toEqual(`${baseCDN}/emojis/${id}.jpg`);
|
||||
});
|
||||
|
||||
test('emoji animated', () => {
|
||||
expect(cdn.emoji(id, true)).toEqual(`${baseCDN}/emojis/${id}.gif`);
|
||||
});
|
||||
|
||||
test('emoji animated with JPG extension', () => {
|
||||
expect(cdn.emoji(id, true, { extension: 'jpg' })).toEqual(`${baseCDN}/emojis/${id}.gif`);
|
||||
});
|
||||
|
||||
test('emoji animated with JPG extension with force static', () => {
|
||||
expect(cdn.emoji(id, true, { extension: 'jpg', forceStatic: true })).toEqual(`${baseCDN}/emojis/${id}.jpg`);
|
||||
});
|
||||
|
||||
test('guildMemberAvatar default', () => {
|
||||
|
||||
@@ -161,10 +161,11 @@ export class CDN {
|
||||
* Generates an emoji's URL.
|
||||
*
|
||||
* @param emojiId - The emoji id
|
||||
* @param animated - Whether the emoji is animated
|
||||
* @param options - Optional options for the emoji
|
||||
*/
|
||||
public emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string {
|
||||
return this.makeURL(`/emojis/${emojiId}`, options);
|
||||
public emoji(emojiId: string, animated: boolean, options?: Readonly<ImageURLOptions>): string {
|
||||
return this.dynamicMakeURL(`/emojis/${emojiId}`, animated ? 'a_' : '', options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user