Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use min_value and max_value to check message count #502

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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