2020-04-16 10:14:13 -04:00
|
|
|
import { Message, User } from 'eris';
|
2020-04-16 10:09:44 -04:00
|
|
|
import { Client, Command } from '../class';
|
|
|
|
|
|
|
|
export default class Unban extends Command {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super(client);
|
|
|
|
this.name = 'unban';
|
|
|
|
this.description = 'Unbans a member from the guild.';
|
|
|
|
this.usage = 'unban <user id> [reason]';
|
|
|
|
this.permissions = 2;
|
|
|
|
this.guildOnly = true;
|
|
|
|
this.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async run(message: Message, args: string[]) {
|
|
|
|
try {
|
2020-04-16 10:14:13 -04:00
|
|
|
let user: User;
|
|
|
|
try {
|
2020-04-16 17:58:10 -04:00
|
|
|
user = await this.client.getRESTUser(args[0]);
|
2020-04-16 10:14:13 -04:00
|
|
|
} catch {
|
2020-04-16 22:56:52 -04:00
|
|
|
return this.error(message.channel, 'Could find find user.');
|
2020-04-16 17:58:10 -04:00
|
|
|
}
|
|
|
|
try {
|
2020-04-17 09:45:18 -04:00
|
|
|
await message.guild.getBan(args[0]);
|
2020-04-16 17:58:10 -04:00
|
|
|
} catch {
|
2020-04-16 22:56:52 -04:00
|
|
|
return this.error(message.channel, 'This user is not banned.');
|
2020-04-16 10:14:13 -04:00
|
|
|
}
|
2020-04-16 10:09:44 -04:00
|
|
|
message.delete();
|
|
|
|
|
|
|
|
await this.client.util.moderation.unban(user.id, message.member, args.slice(1).join(' '));
|
2020-04-16 22:56:52 -04:00
|
|
|
return this.success(message.channel, `${user.username}#${user.discriminator} has been unbanned.`);
|
2020-04-16 10:09:44 -04:00
|
|
|
} catch (err) {
|
|
|
|
return this.client.util.handleError(err, message, this, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|