Beta10110

kick.js

Oct 26th, 2020 (edited)
1,085
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2.  
  3. module.exports = {
  4.     name: 'kick',
  5.     description: "Kicks the specified user from the server.",
  6.     execute(client, message, args){
  7.        
  8.         if (message.member.hasPermission('KICK_MEMBERS')) {
  9.             let target = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
  10.  
  11.             if (target) {
  12.  
  13.                 let reason = args.slice(1).join(" ");
  14.  
  15.                 if (!reason) {
  16.  
  17.                     let embed = new Discord.MessageEmbed()
  18.                     .setTitle('Kick Notice')
  19.                     .setDescription(`You have been kicked from **${message.guild.name}** for the reason: \`Not provided\``)
  20.                     .addField('Moderator', `${message.author.tag} - (${message.author.id})`)
  21.                     .setColor('#ff8282')
  22.                     .setTimestamp();
  23.                    
  24.                     target.send(embed).then(() => {
  25.                         target.kick(`Reason: None.`);
  26.                     }).catch(err => console.log(err));
  27.                     message.channel.send(`${target.user.username} has been kicked.`);                
  28.  
  29.                 };
  30.  
  31.                 let embed = new Discord.MessageEmbed()
  32.                 .setTitle('Kick Notice')
  33.                 .setDescription(`You have been kicked from **${message.guild.name}** for the reason: \`${reason}\`\n\n`)
  34.                 .addField('Moderator', `${message.author.tag} - (${message.author.id})`)
  35.                 .setColor('#ff8282')
  36.                 .setTimestamp();
  37.                
  38.                 target.send(embed).then(() => {
  39.                     target.kick(`Reason: ${reason}`);
  40.                 }).catch(err => console.error(err));
  41.                 message.channel.send(`${target.user.username} has been kicked.`);
  42.  
  43.             } else {
  44.                 message.channel.send(`Please specify a valid user to kick, ${message.author}.`)
  45.             }
  46.         } else {
  47.             message.channel.send(`You do not have the permissions required to kick users, ${message.author}.`);
  48.         };
  49.     }
  50. }
RAW Paste Data