in ,

Create Kick and Ban Command Using discord.js v12

If you having problem in creating the kick and ban command with discord.js new version which is v12 then this post will be very helpful for you. Before you start i shall tell you i will be using handler if you do not know what is handler than read this post – COMMAND HANDLER, So we will start with kick command.

Creating Kick Command

Given below is my command handler setup, i created a file with name kick.js and now i am gonna code in it

const discord = require("discord.js");

module.exports = {
  name: "kick",
  category: "moderation",
  description: "Kick anyone with one shot xD",
  usage: "kick <@user> <raeson>",
  run: (client, message, args) => {

First of all we should let our bot check author permission and his own permissions.

    if(!message.member.hasPermission("KICK_MEMBERS")) {
      return`**${}**, You do not have enough permission to use this command`)
    if(!"KICK_MEMBERS")) {
      return`**${}**, I do not have enough permission to use this command`)

Now we will be defining the Target(person who we want to kick), then add the error message if there author did not mentioned the target.

 let target = message.mentions.members.first();
    if(!target) {
      return`**${}**, Please mention the person who you want to kick`)

We need to make sure that author did not kick himself -_-, so we will add the error message for that also

   if( === {
     return`**${}**, You can not kick yourself`)

we also need to make sure that author must give the reason for kicking member

 if(!args[1]) {
    return`**${}**, Please Give Reason to ban`)

Now we are ready to add main thing, first we will send the embed message then kick the target.

 let embed = new discord.MessageEmbed()
    .setTitle("Action: Kick")
    .setDescription(`Banned ${target} (${})`)
    .setFooter(`Banned by ${}`);

we are done here and you are ready to kick anyone with amazing embed kick command.

Creating Ban Command

Creating ban command is same as kick command but you need to change single thing which is given below


Do not forget to change small things like permissions and embed message 🙂

Re>Resulting Code

Here is the both ban and kick command – CLICK

Related Posts

Written by Senpai

"This may be a virtual world,but I feel more alive here then in the real world"

Leave a Reply