Skip to content

Discord.js v12 Ban Command

I made a ban command for my discord.js v12 bot. However whenever I run the command I get an error. Here is my code:

const Discord = require('discord.js');

module.exports = {
    name: "ban",
    description: "Kicks a member from the server",

    async run (client, message, args) {

        if(!message.member.hasPermission("BAN_MEMBERS")) return'You can't use that!')
        if(!"BAN_MEMBERS")) return'I don't have the right permissions.')

        const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);

        if(!args[0]) return'Please specify a user');

        if(!member) return'Can't seem to find this user. Sorry 'bout that :/');
        if(!member.bannable) return'This user can't be banned. It is either because they are a mod/admin, or their highest role is higher than mine');

        if( === return'Bruh, you can't ban yourself!');

        let reason = args.slice(1).join(" ");

        if(!reason) reason = 'Unspecified';

        member.ban(`${reason}`).catch(err => { 
'Something went wrong')

        const banembed = new Discord.MessageEmbed()
        .setTitle('Member Banned')
        .addField('User Banned', member)
        .addField('Kicked by',
        .addField('Reason', reason)
        .setFooter('Time kicked', client.user.displayAvatarURL())


This is the error I get whenever I run the command

 DiscordAPIError: Invalid Form Body
    DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType
        at RequestHandler.execute (/home/runner/SweatyBeautifulHelpfulWorker/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
        at processTicksAndRejections (internal/process/task_queues.js:97:5) {
      method: 'put',
      path: '/guilds/751424392420130907/bans/155149108183695360',
      code: 50035,
      httpStatus: 400

I could’nt understand how to correct the problem in the code. I’m a bit new to coding. Can you please help me out!. Thanks in advance


This is pretty easy to solve, all you have to to is pass the right amount of Parameters in the right way to the .ban function.

.ban({ days: 7, reason: 'your reason here' })