Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const BaseCommand = require('../../utils/structures/BaseCommand');
- const Discord = require('discord.js')
- module.exports = class UnbanCommand extends BaseCommand {
- constructor() {
- super('unban', 'Moderation', []);
- }
- async run(client, message, args) {
- if(!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("You do not have the permissions to use this command.");
- if(!message.guild.me.hasPermission("BAN_MEMBERS")) return message.channel.send("I dont have the ban permission.")
- let reason =args.slice(1).join(" ");
- let userID = args[0];
- if (!reason) reason = 'No reason given.';
- if (!args[0]) return message.channel.send('You must state someone to unban. `\+unban ID reason\`');
- if (isNaN(args[0])) return message.channel.send('The ID stated is not a number. \`+unban ID reason\`');
- message.guild.fetchBans().then(async bans => {
- if (bans.size == 0) return message.channel.send('This sever does not have anyone banned')
- let bUser = bans.find(b => b.user.id == userID);
- if (!bUser) return message.channel.send('The user ID stated was not banned.')
- await message.guild.members.unban(bUser.user, reason).catch(err => {
- console.log(err);
- return message.channel.send('Something went wrong unbanning the ID.');
- }).then(() => {
- message.channel.send(`Successfully unbanned ${args[0]}`);
- });
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement