Repository: discordjs/discord.js
File: packages/formatters/src/formatters.ts (TypeScript)

Code before:
export function formatEmoji<EmojiId extends Snowflake, Name extends string>({
	emojiId,
	animated,
	name,
}: {
	animated: boolean;
	emojiId: EmojiId;
	name: Name;
}): `<:${Name}:${EmojiId}>` | `<a:${Name}:${EmojiId}>`;

export function formatEmoji<EmojiId extends Snowflake, Name extends string>(
	emojiIdOrOptions: EmojiId | FormatEmojiOptions<EmojiId, Name>,
	animated?: boolean,
	name?: Name,
): `<:${string}:${EmojiId}>` | `<a:${string}:${EmojiId}>` {
	const options =
		typeof emojiIdOrOptions === 'object'
			? emojiIdOrOptions
			: {
					emojiId: emojiIdOrOptions,
					name: name ?? '_',
					animated: animated ?? false,
				};

	const { emojiId, animated: isAnimated, name: emojiName } = options;

	return `<${isAnimated ? 'a' : ''}:${emojiName ?? '_'}:${emojiId}>`;
}

/**
 * @typedef {object} FormatEmojiOptions
 * @property {boolean} [animated] - Whether the emoji is animated
 * @property {EmojiId} emojiId - This is inferred by the supplied emoji id
 * @property {Name} [name] - The name of the emoji
 */
interface FormatEmojiOptions<EmojiId extends Snowflake, Name extends string> {
	animated?: boolean;
	emojiId: EmojiId;
	name?: Name;
}

/**
 * Formats a channel link for a direct message channel.
 *
 * @typeParam ChannelId - This is inferred by the supplied channel id
 * @param channelId - The channel's id
 */
export function channelLink<ChannelId extends Snowflake>(
	channelId: ChannelId,
): `https://discord.com/channels/@me/${ChannelId}`;


Review comment (suggestion):
```suggestion
/**
 * The options for formatting an emoji
 */
interface FormatEmojiOptions<EmojiId extends Snowflake, Name extends string> {
	/**
	 * Whether the emoji is animated
	 */
	animated?: boolean;
	/**
	 * The emoji id to format
	 */
	emojiId: EmojiId;
	/**
	 * The name of the emoji
	 */
	name?: Name;
```

Code after:
	options: FormatEmojiOptions<EmojiId, EmojiName> & { animated?: false },
): `<:${EmojiName}:${EmojiId}>`;

/**
 * Formats an emoji id and name into a fully qualified emoji identifier.
 *
 * @typeParam EmojiId - This is inferred by the supplied emoji id
 * @typeParam EmojiName - This is inferred by the supplied emoji name
 * @param options - The options for formatting an emoji
 */
export function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(
	options: FormatEmojiOptions<EmojiId, EmojiName>,
): `<:${EmojiName}:${EmojiId}>` | `<a:${EmojiName}:${EmojiId}>`;

export function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(
	emojiIdOrOptions: EmojiId | FormatEmojiOptions<EmojiId, EmojiName>,
	animated?: boolean,
): `<:${string}:${EmojiId}>` | `<a:${string}:${EmojiId}>` {
	const options =
		typeof emojiIdOrOptions === 'string'
			? {
					id: emojiIdOrOptions,
					animated: animated ?? false,
				}
			: emojiIdOrOptions;

	const { id, animated: isAnimated, name: emojiName } = options;

	return `<${isAnimated ? 'a' : ''}:${emojiName ?? '_'}:${id}>`;
}

/**
 * The options for formatting an emoji.
 *
 * @typeParam EmojiId - This is inferred by the supplied emoji id
 * @typeParam EmojiName - This is inferred by the supplied emoji name
 */
export interface FormatEmojiOptions<EmojiId extends Snowflake, EmojiName extends string> {
	/**
	 * Whether the emoji is animated
	 */
	animated?: boolean;
	/**
	 * The emoji id to format
	 */
	id: EmojiId;
	/**
	 * The name of the emoji
	 */
	name?: EmojiName;
}