From 169b05f3191a89528b93a07f24358991c2d91c0c Mon Sep 17 00:00:00 2001 From: cobalt <61329810+cobaltt7@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:42:04 -0600 Subject: [PATCH] refactor(formatters): Change `:_:` emoji name placeholder (#10567) * Change `:_:` emoji name placeholder * Update tests * Format --- .../formatters/__tests__/formatters.test.ts | 46 +++++++++++-------- packages/formatters/src/formatters.ts | 8 ++-- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/packages/formatters/__tests__/formatters.test.ts b/packages/formatters/__tests__/formatters.test.ts index c388554b3..a257e56b9 100644 --- a/packages/formatters/__tests__/formatters.test.ts +++ b/packages/formatters/__tests__/formatters.test.ts @@ -169,31 +169,37 @@ describe('Message formatters', () => { }); describe('formatEmoji', () => { - test('GIVEN static emojiId THEN returns "<:_:${emojiId}>"', () => { - expect<`<:_:851461487498493952>`>(formatEmoji('851461487498493952')).toEqual('<:_:851461487498493952>'); + test('GIVEN static emojiId THEN returns "<:emoji:${emojiId}>"', () => { + expect<`<:emoji:851461487498493952>`>(formatEmoji('851461487498493952')).toEqual('<:emoji:851461487498493952>'); }); - test('GIVEN static emojiId WITH animated explicitly false THEN returns "<:_:[emojiId]>"', () => { - expect<`<:_:851461487498493952>`>(formatEmoji('851461487498493952', false)).toEqual('<:_:851461487498493952>'); - }); - - test('GIVEN animated emojiId THEN returns ""', () => { - expect<``>(formatEmoji('827220205352255549', true)).toEqual(''); - }); - - test('GIVEN static id in options object THEN returns "<:_:${id}>"', () => { - expect<`<:_:851461487498493952>`>(formatEmoji({ id: '851461487498493952' })).toEqual('<:_:851461487498493952>'); - }); - - test('GIVEN static id in options object WITH animated explicitly false THEN returns "<:_:${id}>"', () => { - expect<`<:_:851461487498493952>`>(formatEmoji({ animated: false, id: '851461487498493952' })).toEqual( - '<:_:851461487498493952>', + test('GIVEN static emojiId WITH animated explicitly false THEN returns "<:emoji:[emojiId]>"', () => { + expect<`<:emoji:851461487498493952>`>(formatEmoji('851461487498493952', false)).toEqual( + '<:emoji:851461487498493952>', ); }); - test('GIVEN animated id in options object THEN returns ""', () => { - expect<``>(formatEmoji({ animated: true, id: '827220205352255549' })).toEqual( - '', + test('GIVEN animated emojiId THEN returns ""', () => { + expect<``>(formatEmoji('827220205352255549', true)).toEqual( + '', + ); + }); + + test('GIVEN static id in options object THEN returns "<:emoji:${id}>"', () => { + expect<`<:emoji:851461487498493952>`>(formatEmoji({ id: '851461487498493952' })).toEqual( + '<:emoji:851461487498493952>', + ); + }); + + test('GIVEN static id in options object WITH animated explicitly false THEN returns "<:emoji:${id}>"', () => { + expect<`<:emoji:851461487498493952>`>(formatEmoji({ animated: false, id: '851461487498493952' })).toEqual( + '<:emoji:851461487498493952>', + ); + }); + + test('GIVEN animated id in options object THEN returns ""', () => { + expect<``>(formatEmoji({ animated: true, id: '827220205352255549' })).toEqual( + '', ); }); diff --git a/packages/formatters/src/formatters.ts b/packages/formatters/src/formatters.ts index 11c0f0b41..591db60c8 100644 --- a/packages/formatters/src/formatters.ts +++ b/packages/formatters/src/formatters.ts @@ -313,7 +313,7 @@ export function chatInputApplicationCommandMention< * @typeParam EmojiId - This is inferred by the supplied emoji id * @param emojiId - The emoji id to format */ -export function formatEmoji(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`; +export function formatEmoji(emojiId: EmojiId, animated?: false): `<:emoji:${EmojiId}>`; /** * Formats an animated emoji id into a fully qualified emoji identifier. @@ -322,7 +322,7 @@ export function formatEmoji(emojiId: EmojiId, animate * @param emojiId - The emoji id to format * @param animated - Whether the emoji is animated */ -export function formatEmoji(emojiId: EmojiId, animated?: true): ``; +export function formatEmoji(emojiId: EmojiId, animated?: true): ``; /** * Formats an emoji id into a fully qualified emoji identifier. @@ -334,7 +334,7 @@ export function formatEmoji(emojiId: EmojiId, animate export function formatEmoji( emojiId: EmojiId, animated?: boolean, -): `<:_:${EmojiId}>` | ``; +): `<:emoji:${EmojiId}>` | ``; /** * Formats a non-animated emoji id and name into a fully qualified emoji identifier. @@ -383,7 +383,7 @@ export function formatEmoji const { id, animated: isAnimated, name: emojiName } = options; - return `<${isAnimated ? 'a' : ''}:${emojiName ?? '_'}:${id}>`; + return `<${isAnimated ? 'a' : ''}:${emojiName ?? 'emoji'}:${id}>`; } /**