Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. if(message.content.startsWith(`${prefix}kick`)){
  2. const args = message.content.split(' ').slice(1); // All arguments behind the command name with the prefix
  3.  
  4. const user = message.mentions.users.first(); // returns the user object if an user mention exists
  5. const banReason = args.slice(1).join(' '); // Reason of the ban (Everything behind the mention)
  6.  
  7. // Check if an user mention exists in this message
  8. if (!user) {
  9. try {
  10. // Check if a valid userID has been entered instead of a Discord user mention
  11. if (!message.guild.members.get(args.slice(0, 1).join(' '))) throw new Error('Couldn\' get a Discord user with this userID!');
  12. // If the client (bot) can get a user with this userID, it overwrites the current user variable to the user object that the client fetched
  13. user = message.guild.members.get(args.slice(0, 1).join(' '));
  14. user = user.user;
  15. } catch (error) {
  16. return message.reply('Couldn\' get a Discord user with this userID!');
  17. }
  18. }
  19. if (user === message.author) return message.channel.send('You can\'t kick yourself'); // Check if the user mention or the entered userID is the message author himsmelf
  20. if (!banReason) return message.reply('You forgot to enter a reason for this kick!'); // Check if a reason has been given by the message author
  21. if (!message.guild.member(user).bannable) return message.reply('You can\'t kick this user because you the bot has not sufficient permissions!'); // Check if the user is bannable with the bot's permissions
  22. if(!message.member.hasPermission('BAN_MEMBERS')) return message.channel.send('You have insufficient perms to kick this person')
  23. message.guild.kick(user) // Bans the user
  24.  
  25.  
  26. const banConfirmationEmbed = new Discord.RichEmbed()
  27. .setColor('RED')
  28. .setDescription(`✅ ${user.tag} has been successfully kicked!`);
  29. message.channel.send({
  30. embed: banConfirmationEmbed
  31. }); // Sends a confirmation embed that the user has been successfully banned
  32.  
  33.  
  34. const modlogChannelID = ''; // Discord channel ID where you want to have logged the details about the ban
  35. if (modlogChannelID.length !== 0) {
  36. if (!client.channels.get(modlogChannelID )) return undefined; // Check if the modlogChannelID is a real Discord server channel that really exists
  37.  
  38. const banConfirmationEmbedModlog = new Discord.RichEmbed()
  39. .setAuthor(`Kicked by **${message.author.username}#${message.author.discriminator}**`, message.author.displayAvatarURL)
  40. .setThumbnail(user.displayAvatarURL)
  41. .setColor('RED')
  42. .setTimestamp()
  43. .setDescription(`**Action**: Kick
  44. **User**: ${user.username}#${user.discriminator} (${user.id})
  45. **Reason**: ${banReason}`);
  46. client.channels.get(modlogChannelID).send({
  47. embed: banConfirmationEmbedModlog
  48. }); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement