!kick command discord bot code example

Example 1: simple kick command discord.js v12

ban someone discord jsJavascript By Lime on Jun 21 2020
if (!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("Invalid Permissions")
let User = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if (!User) return message.channel.send("Invalid User")
if (User.hasPermission("BAN_MEMBERS")) return message.reply("Invalid Permissions")
let banReason = args.join(" ").slice(22);
if (!banReason) {
  banReason = "None"
}

User.ban({reason: banReason})

Example 2: kick members node js

let kUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!kUser) return message.channel.send("Please mention a user to kick!")
let kReason = args.join(" ").slice(22);
if(!kReason) return message.channel.send ("Please specify some reasons for the kick")
message.guild.member(kUser).kick(kReason);
message.channel.send(`${kUser} has been kicked from the server`);