fix(plugins): createApplicationCommand validation

This commit is contained in:
ITOH
2022-03-24 14:29:01 +01:00
parent c830055a52
commit b0ecdf1a62
@@ -92,13 +92,6 @@ export function createApplicationCommand(bot: BotWithCache) {
// Only slash need to be lowercase
options.name = options.name.toLowerCase();
} else {
if (!CONTEXT_MENU_COMMANDS_NAME_REGEX.test(options.name)) {
throw new Error(
"The name of the context menu did not match the required regex.",
);
}
}
// Slash commands require description
if (
@@ -134,6 +127,13 @@ export function createApplicationCommand(bot: BotWithCache) {
options.options = validateApplicationCommandOptions(bot, options.options);
}
} else {
if (!CONTEXT_MENU_COMMANDS_NAME_REGEX.test(options.name)) {
throw new Error(
"The name of the context menu did not match the required regex.",
);
}
}
return await createApplicationCommandOld(options, guildId);
};