Advertisement
YoJxsn

Untitled

Nov 10th, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. const BaseCommand = require('../../utils/structures/BaseCommand');
  2. const Discord = require('discord.js')
  3. module.exports = class UnbanCommand extends BaseCommand {
  4. constructor() {
  5. super('unban', 'Moderation', []);
  6. }
  7.  
  8. async run(client, message, args) {
  9. if(!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("You do not have the permissions to use this command.");
  10. if(!message.guild.me.hasPermission("BAN_MEMBERS")) return message.channel.send("I dont have the ban permission.")
  11. let reason =args.slice(1).join(" ");
  12. let userID = args[0];
  13.  
  14.  
  15. if (!reason) reason = 'No reason given.';
  16. if (!args[0]) return message.channel.send('You must state someone to unban. `\+unban ID reason\`');
  17. if (isNaN(args[0])) return message.channel.send('The ID stated is not a number. \`+unban ID reason\`');
  18.  
  19. message.guild.fetchBans().then(async bans => {
  20. if (bans.size == 0) return message.channel.send('This sever does not have anyone banned')
  21. let bUser = bans.find(b => b.user.id == userID);
  22. if (!bUser) return message.channel.send('The user ID stated was not banned.')
  23. await message.guild.members.unban(bUser.user, reason).catch(err => {
  24. console.log(err);
  25. return message.channel.send('Something went wrong unbanning the ID.');
  26. }).then(() => {
  27. message.channel.send(`Successfully unbanned ${args[0]}`);
  28. });
  29. });
  30.  
  31.  
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement