【问题标题】:DiscordAPIError: Invalid Form Body description: This field is required for slash jsonDiscordAPIError:无效的表单正文描述:斜线 json 需要此字段
【发布时间】:2022-01-26 18:24:31
【问题描述】:

每当我运行我的机器人时都会收到以下错误:

  method: 'put',
  path: '/applications/[botID]/commands',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object]
    ],
    files: []
  }

从我的index.js 中删除unhandledRejection 错误捕获器后,控制台显示了我在module.exports 下的斜杠命令的JSON,但我似乎无法弄清楚我的描述有什么问题。 这是我的一个 JSON 头的示例:

module.exports = {
  name: "ping",
  description: "Discord API Latency",
  cooldown: 0,
  async execute(client, interaction, Discord, guild) {
    const pingEmbed = new Discord.MessageEmbed()
      .setTitle("Pong! <:ping_pong:879164522307411998>")
      .setDescription(`My ping is ${Math.round(client.ws.ping)}ms`)
      .setColor("#000000");
    interaction.reply({ embeds: [pingEmbed] });
  },
};

【问题讨论】:

  • 我们能看到更多你的代码吗?
  • 我不太确定还要显示什么,因为我很确定这是我所有命令中错误的来源。我只是以 kick 命令为例。
  • 如果您不显示更多可悲的信息,我们无法为您提供更多帮助,错误说明问题出在哪里,描述字段丢失/错误。
  • 我使用完整的 ping 命令编辑了原始帖子,这也会导致错误。
  • 你能检查错误发生在哪一行吗?

标签: discord discord.js


【解决方案1】:

尝试将您的代码更改为 const pingEmbed = new MessageEmbed() 您正在使用 v13 对吗?我认为它会起作用

【讨论】:

    猜你喜欢
    • 2022-10-15
    • 2021-08-04
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 2023-02-26
    • 2020-03-11
    • 2021-07-13
    • 2022-10-18
    相关资源
    最近更新 更多