From c9ef403b741f85c2010387a507d580e8a816c80f Mon Sep 17 00:00:00 2001 From: theimperious1 Date: Fri, 7 Feb 2025 16:06:25 -0500 Subject: [PATCH] Change msg remove text, assume number-only is days --- src/discord/commands/guild/d.moderate.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/discord/commands/guild/d.moderate.ts b/src/discord/commands/guild/d.moderate.ts index 018e8f16..58d53a0b 100644 --- a/src/discord/commands/guild/d.moderate.ts +++ b/src/discord/commands/guild/d.moderate.ts @@ -1568,10 +1568,15 @@ export async function moderate( if (isFullBan(command) || isUnderban(command) || isBanEvasion(command)) { targetData.removed_at = new Date(); - const deleteMessageValue = modalInt.fields.getTextInputValue('days'); + let deleteMessageValue = modalInt.fields.getTextInputValue('days'); let deleteDuration = 0; if (deleteMessageValue !== '') { + // If input is just a number, append 'd' to treat it as days + if (/^\d+$/.test(deleteMessageValue)) { + deleteMessageValue += 'd'; + } + // deleteMessageValue = await makeValid(deleteMessageValue); deleteDuration = parseInt(deleteMessageValue, 10); @@ -1590,6 +1595,7 @@ export async function moderate( return { content: 'Delete duration must be at least 1 second!' }; } } + try { if (deleteDuration > 0 && targetMember) { // log.debug(F, `I am deleting ${deleteMessageValue} days of messages!`); @@ -1980,7 +1986,7 @@ export async function modModal( if (isFullBan(command)) { modal.addComponents(new ActionRowBuilder() .addComponents(new TextInputBuilder() - .setLabel('How many days of msg to remove?') + .setLabel('How far back should messages be removed?') .setStyle(TextInputStyle.Short) .setPlaceholder('7 days or 1 week, etc. (Max 7 days, Default 0 days)') .setRequired(false)