aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/unban.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/moderation/unban.ts')
-rw-r--r--src/commands/moderation/unban.ts85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
new file mode 100644
index 0000000..4f52666
--- /dev/null
+++ b/src/commands/moderation/unban.ts
@@ -0,0 +1,85 @@
+import { BushCommand, BushMessage, BushSlashMessage } from '@lib';
+import { User } from 'discord.js';
+
+export default class UnbanCommand extends BushCommand {
+ public constructor() {
+ super('unban', {
+ aliases: ['unban'],
+ category: 'moderation',
+ description: {
+ content: 'Unban a member from the server.',
+ usage: 'unban <member> <reason> [--delete ]',
+ examples: ['unban 322862723090219008 I changed my mind, commands are allowed in #general']
+ },
+ args: [
+ {
+ id: 'user',
+ type: 'user',
+ prompt: {
+ start: 'What user would you like to unban?',
+ retry: '{error} Choose a valid user to unban.'
+ }
+ },
+ {
+ id: 'reason',
+ type: 'string',
+ match: 'restContent',
+ prompt: {
+ start: 'Why should this user be unbanned?',
+ retry: '{error} Choose a valid unban reason.',
+ optional: true
+ }
+ }
+ ],
+ slash: true,
+ slashOptions: [
+ {
+ name: 'user',
+ description: 'What user would you like to unban?',
+ type: 'USER',
+ required: true
+ },
+ {
+ name: 'reason',
+ description: 'Why should this user be unbanned?',
+ type: 'STRING',
+ required: false
+ }
+ ],
+ channel: 'guild',
+ clientPermissions: ['BAN_MEMBERS'],
+ userPermissions: ['BAN_MEMBERS']
+ });
+ }
+ async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: User; reason?: string }): Promise<unknown> {
+ if (!(user instanceof User)) {
+ user = this.client.util.resolveUser(user, this.client.users.cache);
+ }
+ const response = await message.guild.unban({
+ user,
+ moderator: message.author,
+ reason
+ });
+
+ switch (response) {
+ case 'missing permissions':
+ return message.util.reply(
+ `${this.client.util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`
+ );
+ case 'error unbanning':
+ return message.util.reply(`${this.client.util.emojis.error} An error occurred while trying to unban **${user.tag}**.`);
+ case 'error removing ban entry':
+ return message.util.reply(
+ `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`
+ );
+ case 'error creating modlog entry':
+ return message.util.reply(
+ `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`
+ );
+ case 'user not banned':
+ return message.util.reply(`${this.client.util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`);
+ case 'success':
+ return message.util.reply(`${this.client.util.emojis.success} Successfully unbanned **${user.tag}**.`);
+ }
+ }
+}