Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Ban Command discord.js (v13)

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}`)
      }
  },
};
about 4 years ago ยท Santiago Gelvez
1 answers
Answer question

0

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}` })
    }
}, };
about 4 years ago ยท Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!