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.ts51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index a4c4992..c102434 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -8,10 +8,11 @@ import {
type ArgType,
type CommandMessage,
type OptArgType,
- type SlashMessage
+ type SlashMessage,
+ type UnbanResponse
} from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
+import { ApplicationCommandOptionType, PermissionFlagsBits, type User } from 'discord.js';
export default class UnbanCommand extends BushCommand {
public constructor() {
@@ -60,26 +61,30 @@ export default class UnbanCommand extends BushCommand {
reason
});
- const responseMessage = (): string => {
- const victim = format.input(user.tag);
- switch (responseCode) {
- case unbanResponse.MISSING_PERMISSIONS:
- return `${emojis.error} Could not unban ${victim} because I am missing the **Ban Members** permission.`;
- case unbanResponse.ACTION_ERROR:
- return `${emojis.error} An error occurred while trying to unban ${victim}.`;
- case unbanResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
- return `${emojis.error} While unbanning ${victim}, there was an error removing their ban entry, please report this to my developers.`;
- case unbanResponse.MODLOG_ERROR:
- return `${emojis.error} While unbanning ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
- case unbanResponse.NOT_BANNED:
- return `${emojis.warn} ${victim} is not banned but I tried to unban them anyways.`;
- case unbanResponse.DM_ERROR:
- case unbanResponse.SUCCESS:
- return `${emojis.success} Successfully unbanned ${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: UnbanCommand.formatCode(user, responseCode),
+ allowedMentions: AllowedMentions.none()
+ });
+ }
+
+ public static formatCode(user: User, code: UnbanResponse): string {
+ const victim = format.input(user.tag);
+ switch (code) {
+ case unbanResponse.MISSING_PERMISSIONS:
+ return `${emojis.error} Could not unban ${victim} because I am missing the **Ban Members** permission.`;
+ case unbanResponse.ACTION_ERROR:
+ return `${emojis.error} An error occurred while trying to unban ${victim}.`;
+ case unbanResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
+ return `${emojis.error} While unbanning ${victim}, there was an error removing their ban entry, please report this to my developers.`;
+ case unbanResponse.MODLOG_ERROR:
+ return `${emojis.error} While unbanning ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
+ case unbanResponse.NOT_BANNED:
+ return `${emojis.warn} ${victim} is not banned but I tried to unban them anyways.`;
+ case unbanResponse.DM_ERROR:
+ case unbanResponse.SUCCESS:
+ return `${emojis.success} Successfully unbanned ${victim}.`;
+ default:
+ return `${emojis.error} An error occurred: ${format.input(code)}}`;
+ }
}
}