mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix(plugins): createApplicationCommand checks
This commit is contained in:
@@ -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.",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user