fix(plugins): createApplicationCommand checks

This commit is contained in:
ITOH
2022-03-24 14:34:26 +01:00
parent b0ecdf1a62
commit 75eb35df6e
@@ -83,6 +83,7 @@ export function createApplicationCommand(bot: BotWithCache) {
if (!options.name) {
throw new Error("A name is required to create a options.");
}
if (isChatInput) {
if (!SLASH_COMMANDS_NAME_REGEX.test(options.name)) {
throw new Error(
@@ -94,27 +95,11 @@ export function createApplicationCommand(bot: BotWithCache) {
options.name = options.name.toLowerCase();
// Slash commands require description
if (
!options.description &&
(isChatInput)
) {
if (!options.description) {
throw new Error(
"Slash commands require some form of a description be provided.",
);
}
if (
options.description &&
((options.type === ApplicationCommandTypes.User) ||
(options.type === ApplicationCommandTypes.Message))
) {
throw new Error("Context menu commands do not allow a description.");
}
if (
options.description &&
!bot.utils.validateLength(options.description, { min: 1, max: 100 })
) {
} else if (!bot.utils.validateLength(options.description, { min: 1, max: 100 })) {
throw new Error(
"Application command descriptions must be between 1 and 100 characters.",
);