From 4ba076ba5d9e8b4dc0ad3af30c1a13d339257068 Mon Sep 17 00:00:00 2001 From: ITOH Date: Wed, 12 May 2021 09:00:56 +0200 Subject: [PATCH] change: command names can only be lowercase --- src/types/interactions/commands/application_command.ts | 2 +- src/types/interactions/commands/application_command_option.ts | 2 +- .../commands/create_global_application_command.ts | 2 +- .../interactions/commands/create_guild_application_command.ts | 2 +- .../interactions/commands/edit_global_application_command.ts | 2 +- .../interactions/commands/edit_guild_application_command.ts | 2 +- src/util/utils.ts | 4 +++- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/types/interactions/commands/application_command.ts b/src/types/interactions/commands/application_command.ts index d6ac55f86..ac1d5db22 100644 --- a/src/types/interactions/commands/application_command.ts +++ b/src/types/interactions/commands/application_command.ts @@ -6,7 +6,7 @@ export interface ApplicationCommand { id: string; /** Unique id of the parent application */ applicationId: string; - /** 1-32 character name matching `^[\w-]{1,32}$` */ + /** 1-32 character name matching lowercase `^[\w-]{1,32}$` */ name: string; /** 1-100 character description */ description: string; diff --git a/src/types/interactions/commands/application_command_option.ts b/src/types/interactions/commands/application_command_option.ts index c8ebbfb3d..431e23a30 100644 --- a/src/types/interactions/commands/application_command_option.ts +++ b/src/types/interactions/commands/application_command_option.ts @@ -5,7 +5,7 @@ import { DiscordApplicationCommandOptionTypes } from "./application_command_opti export interface ApplicationCommandOption { /** Value of Application Command Option Type */ type: DiscordApplicationCommandOptionTypes; - /** 1-32 character name matching `^[\w-]{1,32}$` */ + /** 1-32 character name matching lowercase `^[\w-]{1,32}$` */ name: string; /** 1-100 character description */ description: string; diff --git a/src/types/interactions/commands/create_global_application_command.ts b/src/types/interactions/commands/create_global_application_command.ts index 0779e8207..718d8768a 100644 --- a/src/types/interactions/commands/create_global_application_command.ts +++ b/src/types/interactions/commands/create_global_application_command.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOption } from "./application_command_option.ts"; /** https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command-json-params */ export interface CreateGlobalApplicationCommand { - /** 1-31 character name matching `^[\w-]{1,32}$` */ + /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */ name: string; /** 1-100 character description */ description: string; diff --git a/src/types/interactions/commands/create_guild_application_command.ts b/src/types/interactions/commands/create_guild_application_command.ts index 1053452eb..f1447d4c4 100644 --- a/src/types/interactions/commands/create_guild_application_command.ts +++ b/src/types/interactions/commands/create_guild_application_command.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOption } from "./application_command_option.ts"; /** https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command-json-params */ export interface CreateGuildApplicationCommand { - /** 1-31 character name matching `^[\w-]{1,32}$` */ + /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */ name: string; /** 1-100 character description */ description: string; diff --git a/src/types/interactions/commands/edit_global_application_command.ts b/src/types/interactions/commands/edit_global_application_command.ts index da4f9a0b0..6f1c3d0fd 100644 --- a/src/types/interactions/commands/edit_global_application_command.ts +++ b/src/types/interactions/commands/edit_global_application_command.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOption } from "./application_command_option.ts"; /** https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command-json-params */ export interface EditGlobalApplicationCommand { - /** 1-31 character name matching `^[\w-]{1,32}$` */ + /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */ name?: string; /** 1-100 character description */ description?: string; diff --git a/src/types/interactions/commands/edit_guild_application_command.ts b/src/types/interactions/commands/edit_guild_application_command.ts index e3c842694..ddf0f01e9 100644 --- a/src/types/interactions/commands/edit_guild_application_command.ts +++ b/src/types/interactions/commands/edit_guild_application_command.ts @@ -2,7 +2,7 @@ import { ApplicationCommandOption } from "./application_command_option.ts"; /** https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command-json-params */ export interface EditGuildApplicationCommand { - /** 1-31 character name matching `^[\w-]{1,32}$` */ + /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */ name?: string; /** 1-100 character description */ description?: string; diff --git a/src/util/utils.ts b/src/util/utils.ts index b48a71957..045b2250f 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -185,7 +185,9 @@ export function validateSlashCommands( `Running for of loop in validateSlashCommands function.`, ); if ( - (command.name && !SLASH_COMMANDS_NAME_REGEX.test(command.name)) || + (command.name && + (!SLASH_COMMANDS_NAME_REGEX.test(command.name) || + command.name.toLowerCase() !== command.name)) || (create && !command.name) ) { throw new Error(Errors.INVALID_SLASH_NAME);