Advertisement
YoJxsn

Untitled

Nov 4th, 2020
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. const BaseCommand = require('../../utils/structures/BaseCommand');
  2. const Discord = require ('discord.js');
  3.  
  4. module.exports = class KickCommand extends BaseCommand {
  5. constructor() {
  6. super('kick', 'moderation', []);
  7. }
  8.  
  9. async run(client, message, args) {
  10. if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send("You cannot use this command")
  11. const mentionedMember = message.mentions.member.first();
  12. let reason = args.slice(1).join(" ");
  13. if (!reason) reason = "No reason given";
  14. const kickEmbed = new Discord.MessageEmbed()
  15. .setTitle(`You were kicked from ${message.guild.name}`)
  16. .setDescription(`Reason: ${reason}`)
  17. .setColor("#00a170")
  18. .setTimestamp()
  19. .setFooter(client.user.tag, client.user.displayAvatarURL())
  20.  
  21. //+kick @user dm ads
  22. if (!args[0]) return message.channel.send("You need to state a user to kick. \`+kick @user reason\`");
  23. if (!mentionedMember) return message.channel.send("The member mentioned is not in the server.")
  24. try {
  25. await mentionMember.send(kickEmbed);
  26. } catch (err) {
  27. console.Log(`I was unable to message the member.`);
  28. }
  29.  
  30. try {
  31. await mentionedMember.kick(reason);
  32. } catch (err) {
  33. console.Log(err);
  34. return message.channel.send("I was unable to kick the mentioned member.")
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement