@@ -336,11 +336,75 @@ export function formatEmoji<EmojiId extends Snowflake>(
336336 animated ?: boolean ,
337337) : `<:_:${EmojiId } >` | `<a:_:${EmojiId } >`;
338338
339- export function formatEmoji < EmojiId extends Snowflake > (
340- emojiId : EmojiId ,
341- animated = false ,
342- ) : `<:_:${EmojiId } >` | `<a:_:${EmojiId } >` {
343- return `<${ animated ? 'a' : '' } :_:${ emojiId } >` ;
339+ /**
340+ * Formats a non-animated emoji id and name into a fully qualified emoji identifier.
341+ *
342+ * @typeParam EmojiId - This is inferred by the supplied emoji id
343+ * @typeParam EmojiName - This is inferred by the supplied name
344+ * @param options - The options for formatting an emoji
345+ */
346+ export function formatEmoji < EmojiId extends Snowflake , EmojiName extends string > (
347+ options : FormatEmojiOptions < EmojiId , EmojiName > & { animated : true } ,
348+ ) : `<a:${EmojiName } :${EmojiId } >`;
349+
350+ /**
351+ * Formats an animated emoji id and name into a fully qualified emoji identifier.
352+ *
353+ * @typeParam EmojiId - This is inferred by the supplied emoji id
354+ * @typeParam EmojiName - This is inferred by the supplied name
355+ * @param options - The options for formatting an emoji
356+ */
357+ export function formatEmoji < EmojiId extends Snowflake , EmojiName extends string > (
358+ options : FormatEmojiOptions < EmojiId , EmojiName > & { animated ?: false } ,
359+ ) : `<:${EmojiName } :${EmojiId } >`;
360+
361+ /**
362+ * Formats an emoji id and name into a fully qualified emoji identifier.
363+ *
364+ * @typeParam EmojiId - This is inferred by the supplied emoji id
365+ * @typeParam EmojiName - This is inferred by the supplied emoji name
366+ * @param options - The options for formatting an emoji
367+ */
368+ export function formatEmoji < EmojiId extends Snowflake , EmojiName extends string > (
369+ options : FormatEmojiOptions < EmojiId , EmojiName > ,
370+ ) : `<:${EmojiName } :${EmojiId } >` | `<a:${EmojiName } :${EmojiId } >`;
371+
372+ export function formatEmoji < EmojiId extends Snowflake , EmojiName extends string > (
373+ emojiIdOrOptions : EmojiId | FormatEmojiOptions < EmojiId , EmojiName > ,
374+ animated ?: boolean ,
375+ ) : `<:${string } :${EmojiId } >` | `<a:${string } :${EmojiId } >` {
376+ const options =
377+ typeof emojiIdOrOptions === 'string'
378+ ? {
379+ id : emojiIdOrOptions ,
380+ animated : animated ?? false ,
381+ }
382+ : emojiIdOrOptions ;
383+
384+ const { id, animated : isAnimated , name : emojiName } = options ;
385+
386+ return `<${ isAnimated ? 'a' : '' } :${ emojiName ?? '_' } :${ id } >` ;
387+ }
388+
389+ /**
390+ * The options for formatting an emoji.
391+ *
392+ * @typeParam EmojiId - This is inferred by the supplied emoji id
393+ * @typeParam EmojiName - This is inferred by the supplied emoji name
394+ */
395+ export interface FormatEmojiOptions < EmojiId extends Snowflake , EmojiName extends string > {
396+ /**
397+ * Whether the emoji is animated
398+ */
399+ animated ?: boolean ;
400+ /**
401+ * The emoji id to format
402+ */
403+ id : EmojiId ;
404+ /**
405+ * The name of the emoji
406+ */
407+ name ?: EmojiName ;
344408}
345409
346410/**
0 commit comments