【发布时间】:2022-12-18 15:34:17
【问题描述】:
基本上,我最近开始制作不和谐的机器人,并且在子命令后添加字符串输入时遇到问题。我的机器人有一个“黑名单”功能,允许用户添加/删除/查看列入黑名单的单词列表的内容。
如果有帮助的话,这是我希望它成为的语法
加一句话:/blacklist add *word*
删除单词:/blacklist remove *word*
查看列表:/blacklist list
当我添加一个主命令“黑名单”并添加“添加”、“删除”和“列表”的子命令时,在下面添加一个字符串输入字段后出现错误。
起初我试过:
我得到的错误是DiscordAPIError[50035]: Invalid Form Bodyoptions[3][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('blacklist')
.setDescription('Add, remove or view the list of blacklisted words!')
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription('add a word to the blacklist list'))
.addSubcommand(subcommand =>
subcommand
.setName('remove')
.setDescription('remove a word to the blacklist list'))
.addSubcommand(subcommand =>
subcommand
.setName('list')
.setDescription('view the blacklist list'))
.addStringOption(option =>
option.setName('input')
.setDescription('The word you want to add/delete (leave empty if list)')),
async execute(interaction) {
await interaction.reply(interaction.options.getString("input")})
},
};
然后我尝试在每个子命令中添加字符串输入,但不幸的是我得到了相同的结果。
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('blacklist')
.setDescription('Add, remove or view the list of blacklisted words!')
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription('add a word to the blacklist list'))
.addStringOption(option =>
option.setName('adds')
.setDescription('The word you want to add'))
.addSubcommand(subcommand =>
subcommand
.setName('remove')
.setDescription('remove a word to the blacklist list'))
.addStringOption(option =>
option.setName('del')
.setDescription('The word you want to remove'))
.addSubcommand(subcommand =>
subcommand
.setName('list')
.setDescription('view the blacklist list')),
async execute(interaction) {
await interaction.reply(interaction.option.getString("input"))
},
};
DiscordAPIError[50035]: Invalid Form Bodyoptions[1][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other typesoptions[3][APPLICATION_COMMAND_OPTIONS_TYPE_INVALID]: Sub-command and sub-command group option types are mutually exclusive to all other types
我也不确定为什么它说第一个和第三个有问题,而不是第一个和第二个
正如错误消息所述,我明白为什么代码不起作用,但有没有办法解决这个问题?为什么我们不能添加其他选项类型?
【问题讨论】:
标签: node.js discord discord.js