英文:
Discord.js Sub-command and sub-command group option types are mutually exclusive to all other types
问题
I get this error that I really did not understand what it means. Does it say that I can't add options to sub-commands or something?
> DiscordAPIError[50035]: Invalid Form Body
options[1][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
Here is my code:
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { warningSchema } = require('../models/warnings.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('warnings')
.setDescription('complete warning system')
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.addSubcommand((subcommand) =>
subcommand.setName('add')
.setDescription('add a warning to an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true))
.addStringOption((option) =>
option.setName('reason')
.setDescription('reason to warn')
.setRequired(false)))
.addStringOption((option) =>
option.setName('evidence')
.setDescription('evidence to warn')
.setRequired(false))
.addSubcommand((subcommand) =>
subcommand.setName('check')
.setDescription('check warnings of an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true)))
.addSubcommand((subcommand) =>
subcommand.setName('remove')
.setDescription('remove a specific warning of an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true))
.addStringOption((option) =>
option.setName('id')
.setDescription('target warning')
.setRequired(true)))
.addSubcommand((subcommand) =>
subcommand.setName('clear')
.setDescription('clear all warnings of an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true))),
I tried to make sub-commands but got an error that I can't understand.
英文:
I get this error that I really did not understand what it means. Does it say that I can't add options to sub-commands or something?
> DiscordAPIError[50035]: Invalid Form Body
options[1][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
Here is my code:
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { warningSchema } = require('../models/warnings.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('warnings')
.setDescription('complete warning system')
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.addSubcommand((subcommand) =>
subcommand.setName('add')
.setDescription('add a warning to an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true))
.addStringOption((option) =>
option.setName('reason')
.setDescription('reason to warn')
.setRequired(false)))
.addStringOption((option) =>
option.setName('evidence')
.setDescription('evidence to warn')
.setRequired(false))
.addSubcommand((subcommand) =>
subcommand.setName('check')
.setDescription('check warnings of an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true)))
.addSubcommand((subcommand) =>
subcommand.setName('remove')
.setDescription('remove a specific warning of an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true))
.addStringOption((option) =>
option.setName('id')
.setDescription('target warning')
.setRequired(true)))
.addSubcommand((subcommand) =>
subcommand.setName('clear')
.setDescription('clear all warnings of an user')
.addUserOption((option) =>
option.setName('user')
.setDescription('user to warn')
.setRequired(true))),
I tried to make sub-commands but got an error that I can't understand.
答案1
得分: 1
It seems that you have misplaced the closing parenthesis for the first subcommand (where you try to add option.setName('evidence')
).
You cannot mix the addSubcommand()
method with other methods like addStringOption()
. Sub-command and sub-command group option types are mutually exclusive to all other types.
The closing parenthesis should come after the "evidence" string option, not after the "reason" string option:
data: new SlashCommandBuilder()
.setName('warnings')
.setDescription('complete warning system')
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.addSubcommand((subcommand) =>
subcommand
.setName('add')
.setDescription('add a warning to an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('reason')
.setDescription('reason to warn')
.setRequired(false),
)
.addStringOption((option) =>
option
.setName('evidence')
.setDescription('evidence to warn')
.setRequired(false),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('check')
.setDescription('check warnings of an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('remove')
.setDescription('remove a specific warning of an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('id')
.setDescription('target warning')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('clear')
.setDescription('clear all warnings of an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
),
),
英文:
It seems that you have misplaced the closing parenthesis for the first subcommand (where you try to add option.setName('evidence')
).
You cannot mix the addSubcommand()
method with other methods like addStringOption()
. Sub-command and sub-command group option types are mutually exclusive to all other types.
The closing parenthesis should come after the "evidence" string option, not after the "reason" string option:
data: new SlashCommandBuilder()
.setName('warnings')
.setDescription('complete warning system')
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.addSubcommand((subcommand) =>
subcommand
.setName('add')
.setDescription('add a warning to an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('reason')
.setDescription('reason to warn')
.setRequired(false),
)
.addStringOption((option) =>
option
.setName('evidence')
.setDescription('evidence to warn')
.setRequired(false),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('check')
.setDescription('check warnings of an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('remove')
.setDescription('remove a specific warning of an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('id')
.setDescription('target warning')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('clear')
.setDescription('clear all warnings of an user')
.addUserOption((option) =>
option
.setName('user')
.setDescription('user to warn')
.setRequired(true),
),
),
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论