34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { User } from 'eris';
|
|
import { Client, CmdContext, 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(ctx: CmdContext) {
|
|
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
|
|
let user: User;
|
|
try {
|
|
user = await this.client.getRESTUser(ctx.args[0]);
|
|
} catch {
|
|
return this.error(ctx.message.channel, 'Could find find user.');
|
|
}
|
|
try {
|
|
await this.mainGuild.getBan(ctx.args[0]);
|
|
} catch {
|
|
return this.error(ctx.message.channel, 'This user is not banned.');
|
|
}
|
|
ctx.message.delete();
|
|
|
|
await this.client.util.moderation.unban(user.id, ctx.message.member, ctx.args.slice(1).join(' '));
|
|
return this.success(ctx.message.channel, `${user.username}#${user.discriminator} has been unbanned.`);
|
|
}
|
|
}
|