Advertisement
Ryyan

Untitled

Jul 3rd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. const commando = require('discord.js-commando');
  2. const app = require('../../app.js');
  3. const config = require('../../config.json');
  4. const Discord = require('discord.js');
  5.  
  6. class banCommand extends commando.Command {
  7. constructor(client){
  8. super(client, {
  9. name: `ban`,
  10. group: 'message',
  11. memberName: 'ban',
  12. description: 'bans the user mentioned.',
  13. examples: [ 'Ban <@user> being bad!' ]
  14. });
  15. }
  16.  
  17. async run(message, args){
  18. // Most of this command is identical to kick, except that here we'll only let admins do it.
  19. // In the real world mods could ban too, but this is just an example, right? ;)
  20. if (!message.member.roles.some(r => ["Administrator"].includes(r.name)))
  21. return message.reply("Sorry, you don't have permissions to use this!");
  22.  
  23. let member = message.mentions.members.first();
  24. if (!member)
  25. return message.reply("Please mention a valid member of this server");
  26. if (!member.bannable)
  27. return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
  28.  
  29. let reason = args.slice(1).join(' ');
  30. if (!reason) reason = "No reason provided";
  31.  
  32. await member.ban(reason)
  33. .catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
  34. message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
  35. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement