首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不和JS斜杠命令zodError?

不和JS斜杠命令zodError?
EN

Stack Overflow用户
提问于 2022-04-10 04:48:12
回答 1查看 1.6K关注 0票数 0

每当我运行我的代码,我从我的斜杠命令文件中得到一个奇怪的错误,这里是错误。我已经在斜杠命令和命令处理程序中检查了大写名称,尽管我似乎找不到它,也许您可以帮助我?

代码语言:javascript
复制
  {
    "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) 

这是我的斜杠命令。

代码语言:javascript
复制
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))),
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-10 07:42:39

错误中有一个提示:它接收到了undefined,但期望得到一个字符串。这意味着您遗漏了一些东西(而不是一个无效的字符串,例如大写字母)。

您需要添加incognito布尔选项的说明(向方法链添加一个.setDescription() )。

有关命令及其选项所需字段的更多信息,请参见不和谐API文档

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71813833

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档