From 9f5c2035f25678468b847cc6fb092d4d51d2018e Mon Sep 17 00:00:00 2001 From: Suspense <64612795+AlmostSuspense@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:00:35 +0200 Subject: [PATCH 1/2] add min and max value checks Signed-off-by: Suspense <64612795+AlmostSuspense@users.noreply.github.com> --- src/commands/prune.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/commands/prune.ts b/src/commands/prune.ts index c68a6e10..8b3d829a 100644 --- a/src/commands/prune.ts +++ b/src/commands/prune.ts @@ -11,7 +11,12 @@ export default { .setName('prune') .setDescription('Deletes up to 100 messages.') .addIntegerOption((option) => - option.setName('amount').setDescription('Amount of messages to delete').setRequired(true), + option + .setName('amount') + .setDescription('Amount of messages to delete') + .setMinValue(1) + .setMaxValue(100) + .setRequired(true), ) .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction) => { @@ -36,11 +41,7 @@ export default { * The total number of messages to bulkDelete. */ const amount: number = interaction.options.getInteger('amount', true); - - if (amount <= 1 || amount > 100) { - return interaction.reply({ content: '❌ You need to input a number between 1 and 100.', ephemeral: true }); - } - + const textChannel = interaction.channel as TextChannel | NewsChannel; try { const deletedMessages = await textChannel.bulkDelete(amount, true); From e2da6aaf67db4ab3b2cb3f4009810d09ed56a1b2 Mon Sep 17 00:00:00 2001 From: Suspense <64612795+AlmostSuspense@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:06:41 +0200 Subject: [PATCH 2/2] remove invisible stuff Signed-off-by: Suspense <64612795+AlmostSuspense@users.noreply.github.com> --- src/commands/prune.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/prune.ts b/src/commands/prune.ts index 8b3d829a..49f6494a 100644 --- a/src/commands/prune.ts +++ b/src/commands/prune.ts @@ -41,7 +41,6 @@ export default { * The total number of messages to bulkDelete. */ const amount: number = interaction.options.getInteger('amount', true); - const textChannel = interaction.channel as TextChannel | NewsChannel; try { const deletedMessages = await textChannel.bulkDelete(amount, true);