每当我运行我的代码,我从我的斜杠命令文件中得到一个奇怪的错误,这里是错误。我已经在斜杠命令和命令处理程序中检查了大写名称,尽管我似乎找不到它,也许您可以帮助我?
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [],
"message": "Required"
}
]
at handleResult (/home/runner/MI6Agent/node_modules/zod/lib/types.js:28:23)
at ZodString.safeParse (/home/runner/MI6Agent/node_modules/zod/lib/types.js:140:16)
at ZodString.parse (/home/runner/MI6Agent/node_modules/zod/lib/types.js:120:29)
at Y (/home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:5798)
at b (/home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:5893)
at te.runRequiredValidations (/home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:6930)
at te.toJSON (/home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:7116)
at /home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:12954
at Array.map (<anonymous>)
at MixedClass.toJSON (/home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:12945)
at /home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:13239
at Array.map (<anonymous>)
at MixedClass.toJSON (/home/runner/MI6Agent/node_modules/@discordjs/builders/dist/index.js:3:13230)
at Object.<anonymous> (/home/runner/MI6Agent/index.js:33:30)
at Module._compile (node:internal/modules/cjs/loader:1101:14) 这是我的斜杠命令。
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('inform')
.setDescription('Informs the specified user in DMs.')
.addSubcommand(command => command
.setName('channel')
.setDescription('Sends a message to an channel')
.addChannelOption(option => option.setName('target').setDescription('Select the target channel').setRequired(true)).addBooleanOption(option => option.setName('incognito').setRequired(true)))
.addSubcommand(command => command
.setName('member')
.setDescription('Sends a message to an member')
.addUserOption(option => option.setName('target').setDescription('Select the target user').setRequired(true)).addBooleanOption(option => option.setName('incognito').setRequired(true)))
.addSubcommand(command => command
.setName('role')
.setDescription('Sends a message to an member')
.addRoleOption(option => option.setName('target').setDescription('Select the target role').setRequired(true)).addBooleanOption(option => option.setName('incognito').setRequired(true))),
}发布于 2022-04-10 07:42:39
错误中有一个提示:它接收到了undefined,但期望得到一个字符串。这意味着您遗漏了一些东西(而不是一个无效的字符串,例如大写字母)。
您需要添加incognito布尔选项的说明(向方法链添加一个.setDescription() )。
有关命令及其选项所需字段的更多信息,请参见不和谐API文档。
https://stackoverflow.com/questions/71813833
复制相似问题