Advertisement
Guest User

Ban command

a guest
Sep 22nd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. if(cmd === `${prefix}ban`){
  2. let member = message.mentions.members.first() || message.guild.members.get(args[0]);
  3.  
  4. if(!message.member.hasPermission("BAN_MEMBERS")){
  5. const permissionembed = new Discord.RichEmbed()
  6. .setTitle(` Error! `)
  7. .setDescription(`Can't Execute Command`)
  8. .setTimestamp()
  9. .addField(`***Reason:***`, `You do not have permission to use this command`)
  10. .setColor("#db1a09")
  11. .setFooter(`Popuko Tutorial | Ban command`);
  12. message.channel.send(permissionembed);
  13. }else{
  14. if(!member){
  15. const mentionembed = new Discord.RichEmbed()
  16. .setTitle(` Error! `)
  17. .setDescription(`Can't Execute Command`)
  18. .addField(`***Reason:***`, "Please Mention an Valid Member of this server!")
  19. .addField(`Example`, "!ban @user reason")
  20. .setTimestamp()
  21. .setColor(`#db1a09`)
  22. .setFooter(`Popuko Tutorial | Ban Command`);
  23. message.channel.send(mentionembed)
  24. }
  25. if(!member.bannable) {
  26. const cantbanembed = new Discord.RichEmbed()
  27. .setTitle(` Error! `)
  28. .setDescription("I cannot ban this user")
  29. .addField(`***Reason: ***`, `User has an Higher role, Or i do not have enough perms to`)
  30. .setTimestamp()
  31. .setColor("#db1a09")
  32. .setFooter(`Popuko Tutorial | Ban Command`);
  33. message.channel.send(cantbanembed);
  34. }else {
  35. const logs = message.guild.channels.find(channel => channel.name === "plogs");
  36. if(message.guild.me.hasPermission('MANAGE_CHANNELS') && !logs) {
  37. message.guild.createChannel('logs', 'text');
  38. }
  39. let reason = args.slice(1).join(' ');
  40. if(!reason) reason = "No reason provided";
  41.  
  42. member.ban(reason)
  43. .catch(error => message.channel.send(`Sorry ${message.author} I couldn't find the user`));
  44. const banembed = new Discord.RichEmbed()
  45. .setTitle(`🔨 User Banned `)
  46. .setDescription(`${member.user.tag} has been banned`)
  47. .addField(`Moderator`, `${message.author.tag}`)
  48. .addField(`Reason:`, `${reason}`)
  49. .setTimestamp()
  50. .setFooter(`Popuko Tutorial | Ban Command`);
  51. message.channel.send(`🔨 User has been banned`);
  52. logs.send(banembed);
  53.  
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement