无效的Form Body-Discord.js ban命令



我正试图制作一个ban命令,在嵌入中打印信息,但每当我试图执行该命令时,它都会给我一个错误,我不知道如何修复它。

这是我的代码:

if(command === "ban") {
if(!message.member.roles.cache.some(r=>["role"].includes(r.name)))
return message.reply("You do not have permissions to use this command. ``(MOD PERMS)``");
let member = message.mentions.members.first();
if(!member)
return message.reply("Please mention a valid member of this server.");
if(!member.bannable) 
return message.reply("I am unable to ban this user.");
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
await member.ban(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
const user = message.mentions.users.first()
const embedmessage = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle("User was Banned")
.setAuthor(`Moderator: ${message.author.tag}`)
.setDescription(`Banned user: ${member.user.tag}`)
.addFields(
{ name: 'Reason for ban:', value: `${reason}`}
)
.setThumbnail(user.displayAvatarURL());
message.channel.send(embedmessage)
}

这是它显示的错误:

DiscordAPIError: Invalid Form Body
DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType

<GuildMember.ban()>的文档指出,您可以提供的选项应该是一个选项对象。

所以把你的代码改成

await member.ban({reason: reason})

最新更新