简体   繁体   English

我如何解决斜杠 im discord.js 的问题?

[英]how can i solve the problem with slash im discord.js?

my bot worked until yesterday, but I updated it and put some new commands and now this error appears,when I click for my bot to start this error appears: Reason: DiscordAPIError[50035]: Invalid Form Body 2.options[0].type[NUMBER_TYPE_COERCE]: Value "integer" is not int.我的机器人一直工作到昨天,但我更新了它并输入了一些新命令,现在出现此错误,当我单击我的机器人启动此错误时出现:原因:DiscordAPIError [50035]:无效的表单正文 2.options [0]。类型[NUMBER_TYPE_COERCE]:值“整数”不是整数。 and this appears in all bot slashed commands这出现在所有 bot slashed 命令中

here the codes of one of the bot screens:这里是机器人屏幕之一的代码:

const { getVoiceConnection } = require("@discordjs/voice");
module.exports = {
name: "volume",
description: "Changes the Volume of the Music",
options: [
{
  name: "volume",
  description: "Then Volume you want to set",
  type: "INTEGER",
  required: true,
},
],
run: async (client, interaction, args, prefix) => {
if (!interaction.member.voice.channelId)
  return interaction
    .reply({
      ephemeral: true,
      content: "👎 **Please join a Voice-Channel first!**",
    })
    .catch(() => null);
// get an old connection
const oldConnection = getVoiceConnection(interaction.guild.id);
if (!oldConnection)
  return interaction.reply({
    ephemeral: true,
    content: "👎 **I'm not connected somewhere!**",
  });
if (
  oldConnection &&
  oldConnection.joinConfig.channelId != interaction.member.voice.channelId
)
  return interaction
    .reply({
      ephemeral: true,
      content: "👎 **We are not in the same Voice-Channel**!",
    })
    .catch(() => null);

const queue = client.queues.get(interaction.guild.id); // get the queue
if (!queue) {
  return interaction.reply({
    ephemeral: true,
    content: `👎 **Nothing playing right now**`,
  });
}
if (
  !args[0] ||
  isNaN(args[0]) ||
  Number(args[0]) < 1 ||
  Number(args[0]) > 150
)
  return interaction
    .reply({
      ephemeral: true,
      content: `👎 **No __valid__ Volume between 1 and 100 % provided!** Usage: \`${prefix}volume 25\``,
    })
    .catch(() => null);
const volume = Number(args[0]);
queue.volume = volume;

// change the volume
oldConnection.state.subscription.player.state.resource.volume.setVolume(
  volume / 100
);

return interaction
  .reply({
    ephemeral: false,
    content: `🔊 **Successfully changed the Volume to \`${volume}%\`**`,
  })
  .catch(() => null);
  },
  };

You have went from v13 to v14 - this is a breaking change.您已从 v13 升级到 v14 - 这是一个重大变化。 Discord.js implemented a lot of changes that change the way that your bot is developed and code from previous versions in incompatible and requires you to upgrade the code itself. Discord.js 实施了许多更改,这些更改改变了您的机器人的开发方式,并且与以前版本的代码不兼容,并且需要您升级代码本身。

You can view this page on Upgrading from v13 to v14 .您可以在从 v13 升级到 v14上查看此页面。

You have to use the enums in v14.您必须使用 v14 中的枚举。 In this case, ApplicationCommandOptionType在这种情况下, ApplicationCommandOptionType

const { ApplicationCommandOptionType } = require("discord.js")
// ...
  {
    // ...
    type: ApplicationCommandOptionType.Integer
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM