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/timeout.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/timeout.ts')
-rw-r--r-- | src/commands/moderation/timeout.ts | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts index 7be8ecb..1ceedf9 100644 --- a/src/commands/moderation/timeout.ts +++ b/src/commands/moderation/timeout.ts @@ -9,10 +9,11 @@ import { timeoutResponse, type ArgType, type CommandMessage, - type SlashMessage + type SlashMessage, + type TimeoutResponse } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; export default class TimeoutCommand extends BushCommand { public constructor() { @@ -85,25 +86,29 @@ export default class TimeoutCommand extends BushCommand { duration: duration }); - const responseMessage = (): string => { - const victim = format.input(member.user.tag); - switch (responseCode) { - case timeoutResponse.MISSING_PERMISSIONS: - return `${emojis.error} Could not timeout ${victim} because I am missing the **Timeout Members** permission.`; - case timeoutResponse.INVALID_DURATION: - return `${emojis.error} The duration you specified is too long, the longest you can timeout someone for is 28 days.`; - case timeoutResponse.ACTION_ERROR: - return `${emojis.error} An unknown error occurred while trying to timeout ${victim}.`; - case timeoutResponse.MODLOG_ERROR: - return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`; - case timeoutResponse.DM_ERROR: - return `${emojis.warn} Timed out ${victim} however I could not send them a dm.`; - case timeoutResponse.SUCCESS: - return `${emojis.success} Successfully timed out ${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: TimeoutCommand.formatCode(member, responseCode), + allowedMentions: AllowedMentions.none() + }); + } + + public static formatCode(member: GuildMember, code: TimeoutResponse): string { + const victim = format.input(member.user.tag); + switch (code) { + case timeoutResponse.MISSING_PERMISSIONS: + return `${emojis.error} Could not timeout ${victim} because I am missing the **Timeout Members** permission.`; + case timeoutResponse.INVALID_DURATION: + return `${emojis.error} The duration you specified is too long, the longest you can timeout someone for is 28 days.`; + case timeoutResponse.ACTION_ERROR: + return `${emojis.error} An unknown error occurred while trying to timeout ${victim}.`; + case timeoutResponse.MODLOG_ERROR: + return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`; + case timeoutResponse.DM_ERROR: + return `${emojis.warn} Timed out ${victim} however I could not send them a dm.`; + case timeoutResponse.SUCCESS: + return `${emojis.success} Successfully timed out ${victim}.`; + default: + return `${emojis.error} An error occurred: ${format.input(code)}}`; + } } } |