aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/mute.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/moderation/mute.ts')
-rw-r--r--src/commands/moderation/mute.ts60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 12b94d6..5502a84 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -10,11 +10,12 @@ import {
userGuildPermCheck,
type ArgType,
type CommandMessage,
+ type MuteResponse,
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 MuteCommand extends BushCommand {
public constructor() {
@@ -91,32 +92,35 @@ export default class MuteCommand extends BushCommand {
duration
});
- const responseMessage = (): string => {
- const prefix_ = this.client.utils.prefix(message);
- const victim = format.input(member.user.tag);
- switch (responseCode) {
- case muteResponse.MISSING_PERMISSIONS:
- return `${emojis.error} Could not mute ${victim} because I am missing the **Manage Roles** permission.`;
- case muteResponse.NO_MUTE_ROLE:
- return `${emojis.error} Could not mute ${victim}, you must set a mute role with \`${prefix_}config muteRole\`.`;
- case muteResponse.MUTE_ROLE_INVALID:
- return `${emojis.error} Could not mute ${victim} because the current mute role no longer exists. Please set a new mute role with \`${prefix_}config muteRole\`.`;
- case muteResponse.MUTE_ROLE_NOT_MANAGEABLE:
- return `${emojis.error} Could not mute ${victim} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix_}config muteRole\`.`;
- case muteResponse.ACTION_ERROR:
- return `${emojis.error} Could not mute ${victim}, there was an error assigning them the mute role.`;
- case muteResponse.MODLOG_ERROR:
- return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case muteResponse.PUNISHMENT_ENTRY_ADD_ERROR:
- return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
- case muteResponse.DM_ERROR:
- return `${emojis.warn} Muted ${victim} however I could not send them a dm.`;
- case muteResponse.SUCCESS:
- return `${emojis.success} Successfully muted ${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: MuteCommand.formatCode(this.client.utils.prefix(message), member, responseCode),
+ allowedMentions: AllowedMentions.none()
+ });
+ }
+
+ public static formatCode(prefix: string, member: GuildMember, code: MuteResponse): string {
+ const victim = format.input(member.user.tag);
+ switch (code) {
+ case muteResponse.MISSING_PERMISSIONS:
+ return `${emojis.error} Could not mute ${victim} because I am missing the **Manage Roles** permission.`;
+ case muteResponse.NO_MUTE_ROLE:
+ return `${emojis.error} Could not mute ${victim}, you must set a mute role with \`${prefix}config muteRole\`.`;
+ case muteResponse.MUTE_ROLE_INVALID:
+ return `${emojis.error} Could not mute ${victim} because the current mute role no longer exists. Please set a new mute role with \`${prefix}config muteRole\`.`;
+ case muteResponse.MUTE_ROLE_NOT_MANAGEABLE:
+ return `${emojis.error} Could not mute ${victim} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}config muteRole\`.`;
+ case muteResponse.ACTION_ERROR:
+ return `${emojis.error} Could not mute ${victim}, there was an error assigning them the mute role.`;
+ case muteResponse.MODLOG_ERROR:
+ return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
+ case muteResponse.PUNISHMENT_ENTRY_ADD_ERROR:
+ return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
+ case muteResponse.DM_ERROR:
+ return `${emojis.warn} Muted ${victim} however I could not send them a dm.`;
+ case muteResponse.SUCCESS:
+ return `${emojis.success} Successfully muted ${victim}.`;
+ default:
+ return `${emojis.error} An error occurred: ${format.input(code)}}`;
+ }
}
}