diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-07-06 22:10:58 +0200 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-07-06 22:10:58 +0200 |
commit | adbb5e939cebcf4c0479d66162377957f2a845af (patch) | |
tree | e69b237c79fac2701f162fce6076ec1f85f617a9 /src/commands/moderation/ban.ts | |
parent | 22b3a8af49dc16bf5d8f9c3ce48b4770505ea33b (diff) | |
download | tanzanite-adbb5e939cebcf4c0479d66162377957f2a845af.tar.gz tanzanite-adbb5e939cebcf4c0479d66162377957f2a845af.tar.bz2 tanzanite-adbb5e939cebcf4c0479d66162377957f2a845af.zip |
feat(automod): unmute button
Diffstat (limited to 'src/commands/moderation/ban.ts')
-rw-r--r-- | src/commands/moderation/ban.ts | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 598fcaa..1b045aa 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -8,12 +8,13 @@ import { format, Moderation, type ArgType, + type BanResponse, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, type User } from 'discord.js'; export default class BanCommand extends BushCommand { public constructor() { @@ -109,27 +110,31 @@ export default class BanCommand extends BushCommand { const responseCode = member ? await member.bushBan(opts) : await message.guild.bushBan({ user, ...opts }); - const responseMessage = (): string => { - const victim = format.input(user.tag); - switch (responseCode) { - case banResponse.ALREADY_BANNED: - return `${emojis.error} ${victim} is already banned.`; - case banResponse.MISSING_PERMISSIONS: - return `${emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`; - case banResponse.ACTION_ERROR: - return `${emojis.error} An error occurred while trying to ban ${victim}.`; - case banResponse.PUNISHMENT_ENTRY_ADD_ERROR: - return `${emojis.error} While banning ${victim}, there was an error creating a ban entry, please report this to my developers.`; - case banResponse.MODLOG_ERROR: - return `${emojis.error} While banning ${victim}, there was an error creating a modlog entry, please report this to my developers.`; - case banResponse.DM_ERROR: - return `${emojis.warn} Banned ${victim} however I could not send them a dm.`; - case banResponse.SUCCESS: - return `${emojis.success} Successfully banned ${victim}.`; - default: - return `${emojis.error} An error occurred: ${format.input(responseCode)}}`; - } - }; - return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); + return await message.util.reply({ + content: BanCommand.formatCode(user, responseCode), + allowedMentions: AllowedMentions.none() + }); + } + + public static formatCode(user: User, code: BanResponse): string { + const victim = format.input(user.tag); + switch (code) { + case banResponse.ALREADY_BANNED: + return `${emojis.error} ${victim} is already banned.`; + case banResponse.MISSING_PERMISSIONS: + return `${emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`; + case banResponse.ACTION_ERROR: + return `${emojis.error} An error occurred while trying to ban ${victim}.`; + case banResponse.PUNISHMENT_ENTRY_ADD_ERROR: + return `${emojis.error} While banning ${victim}, there was an error creating a ban entry, please report this to my developers.`; + case banResponse.MODLOG_ERROR: + return `${emojis.error} While banning ${victim}, there was an error creating a modlog entry, please report this to my developers.`; + case banResponse.DM_ERROR: + return `${emojis.warn} Banned ${victim} however I could not send them a dm.`; + case banResponse.SUCCESS: + return `${emojis.success} Successfully banned ${victim}.`; + default: + return `${emojis.error} An error occurred: ${format.input(code)}}`; + } } } |