37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Message, User } from 'eris';
|
|
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 = 3;
|
|
this.guildOnly = true;
|
|
this.enabled = true;
|
|
}
|
|
|
|
public async run(message: Message, args: string[]) {
|
|
try {
|
|
let user: User;
|
|
try {
|
|
user = await this.client.getRESTUser(args[0]);
|
|
} catch {
|
|
return this.error(message.channel, 'Could find find user.');
|
|
}
|
|
try {
|
|
await this.client.guilds.get(this.client.config.guildID).getBan(args[0]);
|
|
} catch {
|
|
return this.error(message.channel, 'This user is not banned.');
|
|
}
|
|
message.delete();
|
|
|
|
await this.client.util.moderation.unban(user.id, message.member, args.slice(1).join(' '));
|
|
return this.success(message.channel, `${user.username}#${user.discriminator} has been unbanned.`);
|
|
} catch (err) {
|
|
return this.client.util.handleError(err, message, this, false);
|
|
}
|
|
}
|
|
}
|