Hello I've been trying to make a ban command with discord.js (v13) but I am getting this error and I don't know what is the cause of a problem
If anyone can help I would be very grateful
DiscordAPIError: Invalid Form Body
embeds[0].description: This field is required
My code:
module.exports = {
name: "ban",
description: "This command ban's someone",
category: "moderation",
example: ["!ban @member"],
callback: async ({ message, args }) => {
try {
const member = message.mentions.members.first();
const permission = message.member.permissions.has("BAN_MEMBERS");
if (!permission)
return message.reply(
"❌ | You don't have permission to use this command"
);
if (!args[0]) return message.reply(`❌ | Please specify someone`);
if (!member) return message.reply(`💤 | Cannot find that member...`);
if (member.id === message.author.id)
return message.reply(`❌ | You cannot ban yourself!`);
if (message.member.roles.highest.position < member.roles.highest.position)
return message.reply(
`❌ | You cannot ban user who have higher role than you...`
);
if (!member.bannable) return message.reply(`❌ | I cannot ban that member`);
return (
(await member.ban()) +
message
.reply({
content: `:anger: | User ${member} has been banned`,
})
.then((msg) => {
setTimeout(() => msg.delete(), 5000);
})
);
} catch(err) {
message.reply(`awww there was an ${err}`)
}
},
};
If you're updating discord.js from v12 to v13, make sure to keep these changes in mind: https://discordjs.guide/additional-info/changes-in-v13.html#sending-messages-embeds-files-etc
The embeds option was replaced with embeds arrays, meaning they must be in the options object. Try this code out:
module.exports = {
name: "ban",
description: "This command ban's someone",
category: "moderation",
example: ["!ban @member"],
callback: async ({ message, args }) => {
try {
const member = message.mentions.members.first();
const permission = message.member.permissions.has(Discord.Permissions.FLAGS.BAN_MEMBERS)
if (!permission)
return message.reply({
contents: "❌ | You don't have permission to use this command"
});
if (!args[0]) return message.reply({ content: `❌ | Please specify someone` });
if (!member) return message.reply({ content: `💤 | Cannot find that member...` } );
if (member.id === message.author.id)
return message.reply({ content: `❌ | You cannot ban yourself!` });
if (message.member.roles.highest.position < member.roles.highest.position)
return message.reply({
content: `❌ | You cannot ban user who have higher role than you...`
});
if (!member.bannable) return message.reply({ content: `❌ | I cannot ban that member`});
return (
(await member.ban()) +
message
.reply({
content: `:anger: | User ${member} has been banned`
})
.then((msg) => {
setTimeout(() => msg.delete(), 5000);
})
);
} catch(err) {
message.reply({ content: `awww there was an ${err}` })
}
}, };
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.