From 51c3bf1f54332e166dd1ca554d09cb5c197be0e4 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 26 Mar 2023 00:05:00 +0100 Subject: [PATCH] feat: backport `chatInputApplicationCommandMention` (#9245) feat: chatInputApplicationCommandMention formatter --- src/util/Formatters.js | 30 ++++++++++++++++++++++++++++++ typings/index.d.ts | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/src/util/Formatters.js b/src/util/Formatters.js index aa5888fd0..439a51734 100644 --- a/src/util/Formatters.js +++ b/src/util/Formatters.js @@ -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 ``; + } + + if (typeof subcommandNameOrId !== 'undefined') { + return ``; + } + + return ``; +}; + /** * Wraps the content inside a code block with an optional language. * @method codeBlock diff --git a/typings/index.d.ts b/typings/index.d.ts index 05a266e7b..d1eff3bfa 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2775,6 +2775,10 @@ export class Formatters extends null { public static blockQuote: typeof blockQuote; public static bold: typeof bold; public static channelMention: typeof channelMention; + public static chatInputApplicationCommandMention + (commandName: N, subcommandGroupName: G, subcommandName: S, commandId: I): ``; + public static chatInputApplicationCommandMention(commandName: N, subcommandName: S, commandId: I): ``; + public static chatInputApplicationCommandMention(commandName: N, commandId: I): ``; public static codeBlock: typeof codeBlock; public static formatEmoji: typeof formatEmoji; public static hideLinkEmbed: typeof hideLinkEmbed;