feat: backport chatInputApplicationCommandMention (#9245)

feat: chatInputApplicationCommandMention formatter
This commit is contained in:
Jaw0r3k
2023-03-26 00:05:00 +01:00
committed by GitHub
parent b9b037b886
commit 51c3bf1f54
2 changed files with 34 additions and 0 deletions

View File

@@ -52,6 +52,36 @@ Formatters.bold = bold;
*/
Formatters.channelMention = channelMention;
/**
* Formats an application command name, subcommand group name, subcommand name, and ID
* into an application command mention
* @method chatInputApplicationCommandMention
* @memberof Formatters
* @param {string} commandName The name of the application command
* @param {string|Snowflake} subcommandGroupOrSubOrId
* The subcommand group name, subcommand name, or application command id
* @param {?(string|Snowflake)} [subcommandNameOrId] The subcommand name or application command id
* @param {?Snowflake} [commandId] The id of the application command
* @returns {string}
* @static
*/
Formatters.chatInputApplicationCommandMention = function chatInputApplicationCommandMention(
commandName,
subcommandGroupOrSubOrId,
subcommandNameOrId,
commandId,
) {
if (typeof commandId !== 'undefined') {
return `</${commandName} ${subcommandGroupOrSubOrId} ${subcommandNameOrId}:${commandId}>`;
}
if (typeof subcommandNameOrId !== 'undefined') {
return `</${commandName} ${subcommandGroupOrSubOrId}:${subcommandNameOrId}>`;
}
return `</${commandName}:${subcommandGroupOrSubOrId}>`;
};
/**
* Wraps the content inside a code block with an optional language.
* @method codeBlock