From 5d03c9ddf89c68a7676d33f630a51c7f75383239 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Sat, 4 May 2024 09:48:26 +1000 Subject: [PATCH] Add duration limit to `/mute` --- src/components/Punish.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Punish.ts b/src/components/Punish.ts index 77f7e0c..fb7ed8a 100644 --- a/src/components/Punish.ts +++ b/src/components/Punish.ts @@ -2,6 +2,7 @@ import Discord from 'discord.js'; import TClient from '../client.js'; import MessageTool from '../helpers/MessageTool.js'; import Logger from '../helpers/Logger.js'; +import ms from 'ms'; export default async(client:TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: 'ban'|'softban'|'kick'|'mute'|'warn'|'remind')=>{ if (!MessageTool.isModerator(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod'); @@ -11,6 +12,7 @@ export default async(client:TClient, interaction: Discord.ChatInputCommandIntera const GuildMember = interaction.options.getMember('member') ?? undefined; const User = interaction.options.getUser('member', true); if (reason.length > 1020) return interaction.reply({content: 'Reason cannot be longer than 1020 characters due to Discord\'s limit.', ephemeral: true}); + if (type.includes('mute') && ms(time) > 2419200000) return interaction.reply({content: 'Duration cannot exceed 4 weeks, try again!', ephemeral: true}); const punishLog = `\`${GuildMember?.user?.username ?? User?.username ?? 'No user data'}\` ${time ? ['warn', 'kick'].includes(type) ? 'and no duration set' : `and \`${time}\` (duration)` : ''} was used in \`/${interaction.commandName}\` for \`${reason}\``; Logger.console('log', 'PunishmentLog', punishLog);