mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
feat: add chatInputApplicationCommandMention formatter (#8546)
feat: add `chatInputApplicationCommandMention()` formatter Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -180,6 +180,75 @@ export function roleMention<C extends Snowflake>(roleId: C): `<@&${C}>` {
|
||||
return `<@&${roleId}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention
|
||||
*
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandGroupName - The subcommand group name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command ID to format
|
||||
*/
|
||||
export function chatInputApplicationCommandMention<
|
||||
N extends string,
|
||||
G extends string,
|
||||
S extends string,
|
||||
I extends Snowflake,
|
||||
>(commandName: N, subcommandGroupName: G, subcommandName: S, commandId: I): `</${N} ${G} ${S}:${I}>`;
|
||||
|
||||
/**
|
||||
* Formats an application command name, subcommand name, and ID into an application command mention
|
||||
*
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command ID to format
|
||||
*/
|
||||
export function chatInputApplicationCommandMention<N extends string, S extends string, I extends Snowflake>(
|
||||
commandName: N,
|
||||
subcommandName: S,
|
||||
commandId: I,
|
||||
): `</${N} ${S}:${I}>`;
|
||||
|
||||
/**
|
||||
* Formats an application command name and ID into an application command mention
|
||||
*
|
||||
* @param commandName - The application command name to format
|
||||
* @param commandId - The application command ID to format
|
||||
*/
|
||||
export function chatInputApplicationCommandMention<N extends string, I extends Snowflake>(
|
||||
commandName: N,
|
||||
commandId: I,
|
||||
): `</${N}:${I}>`;
|
||||
|
||||
/**
|
||||
* Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention
|
||||
*
|
||||
* @param commandName - The application command name to format
|
||||
* @param subcommandGroupName - The subcommand group name to format
|
||||
* @param subcommandName - The subcommand name to format
|
||||
* @param commandId - The application command ID to format
|
||||
*/
|
||||
export function chatInputApplicationCommandMention<
|
||||
N extends string,
|
||||
G extends Snowflake | string,
|
||||
S extends Snowflake | string,
|
||||
I extends Snowflake,
|
||||
>(
|
||||
commandName: N,
|
||||
subcommandGroupName: G,
|
||||
subcommandName?: S,
|
||||
commandId?: I,
|
||||
): `</${N} ${G} ${S}:${I}>` | `</${N} ${G}:${S}>` | `</${N}:${G}>` {
|
||||
if (typeof commandId !== 'undefined') {
|
||||
return `</${commandName} ${subcommandGroupName} ${subcommandName!}:${commandId}>`;
|
||||
}
|
||||
|
||||
if (typeof subcommandName !== 'undefined') {
|
||||
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
||||
}
|
||||
|
||||
return `</${commandName}:${subcommandGroupName}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an emoji ID into a fully qualified emoji identifier
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user