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/block.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/block.ts')
-rw-r--r-- | src/commands/moderation/block.ts | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts index fc93fb1..48436eb 100644 --- a/src/commands/moderation/block.ts +++ b/src/commands/moderation/block.ts @@ -9,12 +9,13 @@ import { Moderation, userGuildPermCheck, type ArgType, + type BlockResponse, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; export default class BlockCommand extends BushCommand { public constructor() { @@ -97,27 +98,31 @@ export default class BlockCommand extends BushCommand { channel: message.channel }); - const responseMessage = (): string => { - const victim = format.input(member.user.tag); - switch (responseCode) { - case blockResponse.MISSING_PERMISSIONS: - return `${emojis.error} Could not block ${victim} because I am missing the **Manage Channel** permission.`; - case blockResponse.INVALID_CHANNEL: - return `${emojis.error} Could not block ${victim}, you can only block users in text or thread channels.`; - case blockResponse.ACTION_ERROR: - return `${emojis.error} An unknown error occurred while trying to block ${victim}.`; - case blockResponse.MODLOG_ERROR: - return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`; - case blockResponse.PUNISHMENT_ENTRY_ADD_ERROR: - return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`; - case blockResponse.DM_ERROR: - return `${emojis.warn} Blocked ${victim} however I could not send them a dm.`; - case blockResponse.SUCCESS: - return `${emojis.success} Successfully blocked ${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: BlockCommand.formatCode(member, responseCode), + allowedMentions: AllowedMentions.none() + }); + } + + public static formatCode(member: GuildMember, code: BlockResponse): string { + const victim = format.input(member.user.tag); + switch (code) { + case blockResponse.MISSING_PERMISSIONS: + return `${emojis.error} Could not block ${victim} because I am missing the **Manage Channel** permission.`; + case blockResponse.INVALID_CHANNEL: + return `${emojis.error} Could not block ${victim}, you can only block users in text or thread channels.`; + case blockResponse.ACTION_ERROR: + return `${emojis.error} An unknown error occurred while trying to block ${victim}.`; + case blockResponse.MODLOG_ERROR: + return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`; + case blockResponse.PUNISHMENT_ENTRY_ADD_ERROR: + return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`; + case blockResponse.DM_ERROR: + return `${emojis.warn} Blocked ${victim} however I could not send them a dm.`; + case blockResponse.SUCCESS: + return `${emojis.success} Successfully blocked ${victim}.`; + default: + return `${emojis.error} An error occurred: ${format.input(code)}}`; + } } } |