change: command names can only be lowercase

This commit is contained in:
ITOH
2021-05-12 09:00:56 +02:00
parent 81f1186b23
commit 4ba076ba5d
7 changed files with 9 additions and 7 deletions
@@ -6,7 +6,7 @@ export interface ApplicationCommand {
id: string; id: string;
/** Unique id of the parent application */ /** Unique id of the parent application */
applicationId: string; applicationId: string;
/** 1-32 character name matching `^[\w-]{1,32}$` */ /** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
name: string; name: string;
/** 1-100 character description */ /** 1-100 character description */
description: string; description: string;
@@ -5,7 +5,7 @@ import { DiscordApplicationCommandOptionTypes } from "./application_command_opti
export interface ApplicationCommandOption { export interface ApplicationCommandOption {
/** Value of Application Command Option Type */ /** Value of Application Command Option Type */
type: DiscordApplicationCommandOptionTypes; type: DiscordApplicationCommandOptionTypes;
/** 1-32 character name matching `^[\w-]{1,32}$` */ /** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
name: string; name: string;
/** 1-100 character description */ /** 1-100 character description */
description: string; description: string;
@@ -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 */ /** https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command-json-params */
export interface CreateGlobalApplicationCommand { export interface CreateGlobalApplicationCommand {
/** 1-31 character name matching `^[\w-]{1,32}$` */ /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */
name: string; name: string;
/** 1-100 character description */ /** 1-100 character description */
description: string; description: string;
@@ -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 */ /** https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command-json-params */
export interface CreateGuildApplicationCommand { export interface CreateGuildApplicationCommand {
/** 1-31 character name matching `^[\w-]{1,32}$` */ /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */
name: string; name: string;
/** 1-100 character description */ /** 1-100 character description */
description: string; description: string;
@@ -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 */ /** https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command-json-params */
export interface EditGlobalApplicationCommand { export interface EditGlobalApplicationCommand {
/** 1-31 character name matching `^[\w-]{1,32}$` */ /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */
name?: string; name?: string;
/** 1-100 character description */ /** 1-100 character description */
description?: string; description?: string;
@@ -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 */ /** https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command-json-params */
export interface EditGuildApplicationCommand { export interface EditGuildApplicationCommand {
/** 1-31 character name matching `^[\w-]{1,32}$` */ /** 1-31 character name matching lowercase `^[\w-]{1,32}$` */
name?: string; name?: string;
/** 1-100 character description */ /** 1-100 character description */
description?: string; description?: string;
+3 -1
View File
@@ -185,7 +185,9 @@ export function validateSlashCommands(
`Running for of loop in validateSlashCommands function.`, `Running for of loop in validateSlashCommands function.`,
); );
if ( 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) (create && !command.name)
) { ) {
throw new Error(Errors.INVALID_SLASH_NAME); throw new Error(Errors.INVALID_SLASH_NAME);