aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/unblock.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-07-06 22:10:58 +0200
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-07-06 22:10:58 +0200
commitadbb5e939cebcf4c0479d66162377957f2a845af (patch)
treee69b237c79fac2701f162fce6076ec1f85f617a9 /src/commands/moderation/unblock.ts
parent22b3a8af49dc16bf5d8f9c3ce48b4770505ea33b (diff)
downloadtanzanite-adbb5e939cebcf4c0479d66162377957f2a845af.tar.gz
tanzanite-adbb5e939cebcf4c0479d66162377957f2a845af.tar.bz2
tanzanite-adbb5e939cebcf4c0479d66162377957f2a845af.zip
feat(automod): unmute button
Diffstat (limited to 'src/commands/moderation/unblock.ts')
-rw-r--r--src/commands/moderation/unblock.ts53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts
index 09ec281..f8a57f8 100644
--- a/src/commands/moderation/unblock.ts
+++ b/src/commands/moderation/unblock.ts
@@ -10,10 +10,11 @@ import {
type ArgType,
type CommandMessage,
type OptArgType,
- type SlashMessage
+ type SlashMessage,
+ type UnblockResponse
} from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js';
export default class UnblockCommand extends BushCommand {
public constructor() {
@@ -88,27 +89,31 @@ export default class UnblockCommand extends BushCommand {
channel: message.channel
});
- const responseMessage = (): string => {
- const victim = format.input(member.user.tag);
- switch (responseCode) {
- case unblockResponse.MISSING_PERMISSIONS:
- return `${emojis.error} Could not unblock ${victim} because I am missing the **Manage Channel** permission.`;
- case unblockResponse.INVALID_CHANNEL:
- return `${emojis.error} Could not unblock ${victim}, you can only unblock users in text or thread channels.`;
- case unblockResponse.ACTION_ERROR:
- return `${emojis.error} An unknown error occurred while trying to unblock ${victim}.`;
- case unblockResponse.MODLOG_ERROR:
- return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case unblockResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
- return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
- case unblockResponse.DM_ERROR:
- return `${emojis.warn} Unblocked ${victim} however I could not send them a dm.`;
- case unblockResponse.SUCCESS:
- return `${emojis.success} Successfully unblocked ${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: UnblockCommand.formatCode(member, responseCode),
+ allowedMentions: AllowedMentions.none()
+ });
+ }
+
+ public static formatCode(member: GuildMember, code: UnblockResponse): string {
+ const victim = format.input(member.user.tag);
+ switch (code) {
+ case unblockResponse.MISSING_PERMISSIONS:
+ return `${emojis.error} Could not unblock ${victim} because I am missing the **Manage Channel** permission.`;
+ case unblockResponse.INVALID_CHANNEL:
+ return `${emojis.error} Could not unblock ${victim}, you can only unblock users in text or thread channels.`;
+ case unblockResponse.ACTION_ERROR:
+ return `${emojis.error} An unknown error occurred while trying to unblock ${victim}.`;
+ case unblockResponse.MODLOG_ERROR:
+ return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
+ case unblockResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
+ return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
+ case unblockResponse.DM_ERROR:
+ return `${emojis.warn} Unblocked ${victim} however I could not send them a dm.`;
+ case unblockResponse.SUCCESS:
+ return `${emojis.success} Successfully unblocked ${victim}.`;
+ default:
+ return `${emojis.error} An error occurred: ${format.input(code)}}`;
+ }
}
}