From cb5ad6c7db00a31194e301110c522b79c80524b5 Mon Sep 17 00:00:00 2001 From: GHOST Date: Sat, 20 Apr 2024 20:41:47 +0100 Subject: [PATCH] fix: use correct regex for validating slash command names --- .changeset/many-items-pull.md | 5 +++++ .../src/commands/types/commands/options.ts | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 .changeset/many-items-pull.md diff --git a/.changeset/many-items-pull.md b/.changeset/many-items-pull.md new file mode 100644 index 0000000..fd73c86 --- /dev/null +++ b/.changeset/many-items-pull.md @@ -0,0 +1,5 @@ +--- +"jellycommands": patch +--- + +fix: use correct regex for validating slash command names diff --git a/packages/jellycommands/src/commands/types/commands/options.ts b/packages/jellycommands/src/commands/types/commands/options.ts index a920f1b..3d908b9 100644 --- a/packages/jellycommands/src/commands/types/commands/options.ts +++ b/packages/jellycommands/src/commands/types/commands/options.ts @@ -22,15 +22,11 @@ export interface CommandOptions extends BaseOptions { } export const commandSchema = baseCommandSchema.extend({ - name: z - .string() - .min(1, 'Slash command name must be at least 1 char long') - .max(32, 'Slash command name cannot exceed 32 chars') - .regex( - /^[a-z0-9]+$/, - 'Slash command name must be all lowercase, alphanumeric, and at most 32 chars long', - ) - .refine((str) => str.toLowerCase() == str, 'Slash command name must be lowercase'), + name: z.string().regex( + // https://discord.com/developers/docs/interactions/application-commands#application-command-object + /^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u, + 'Slash command name must be all lowercase, alphanumeric, and at most 32 chars long', + ), description: z .string({ required_error: 'Slash command description is required' })