Skip to content

Commit

Permalink
refactor(cmds/prune): use min and max values in options (#502)
Browse files Browse the repository at this point in the history
Signed-off-by: Suspense <64612795+AlmostSuspense@users.noreply.github.com>
  • Loading branch information
AlmostSuspense committed Jul 18, 2022
1 parent f66f0a8 commit f797e6b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/commands/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -36,11 +41,6 @@ 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);
Expand Down

0 comments on commit f797e6b

Please sign in to comment.