[英]how can i solve the problem with slash im discord.js?
我的機器人一直工作到昨天,但我更新了它並輸入了一些新命令,現在出現此錯誤,當我單擊我的機器人啟動此錯誤時出現:原因:DiscordAPIError [50035]:無效的表單正文 2.options [0]。類型[NUMBER_TYPE_COERCE]:值“整數”不是整數。 這出現在所有 bot slashed 命令中
這里是機器人屏幕之一的代碼:
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);
},
};
您已從 v13 升級到 v14 - 這是一個重大變化。 Discord.js 實施了許多更改,這些更改改變了您的機器人的開發方式,並且與以前版本的代碼不兼容,並且需要您升級代碼本身。
您可以在從 v13 升級到 v14上查看此頁面。
您必須使用 v14 中的枚舉。 在這種情況下, ApplicationCommandOptionType
const { ApplicationCommandOptionType } = require("discord.js")
// ...
{
// ...
type: ApplicationCommandOptionType.Integer
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.