Skip to content
Snippets Groups Projects
Commit 7bea4a93 authored by Reviath's avatar Reviath
Browse files

Added unban command.

parent 72942721
No related branches found
No related tags found
No related merge requests found
const errors = require('../errors.json');
exports.run = async (client, message, args) => {
if (!message.member.hasPermission('BAN_MEMBERS')) {
message.channel.send(errors.insufficient_permission_for_user).catch(e => {
return;
});
return;
};
function GetUser(user) {
if (user.length == 18) {
return user;
} else if (user.length == 22) {
return user.slice(3, 21);
} else if (user.length == 21) {
return user.slice(3, 20);
} else {
return user;
};
};
const user = args[0]
if (!user) {
message.channel.send(errors.insufficient_args).catch(e => {
return;
});
return;
};
let reason = args.slice(1).join(' ');
if (!reason) {
reason = "Unspecified."
}
message.guild.fetchBans().then(bans => {
if(bans.size == 0) {
message.channel.send('There is no ban on this guild.').catch(e => {
return;
});
return;
};
const ban = bans.find(b => b.user.id == GetUser(user));
if (!ban) {
message.channel.send('Cannot find that user or that user is not banned.').catch(e => {
return;
});
return
};
message.guild.members.unban(ban.user).catch(e => {
message.channel.send(errors.insufficient_permission_for_bot).catch(e => {
return;
});
return;
});
message.channel.send('Successfully performed unban on specified user.').catch(e => {
return;
});
});
};
module.exports.help = {
name: 'unban',
aliases: []
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment