aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands/rm.js
blob: ec6f6477359ac184732dd11996cc067486196768 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js';

export default {
    data: new SlashCommandBuilder()
        .setName('rm')
        .setDescription('Purges messages.')
        .addNumberOption(option =>
            option
                .setName('amount')
                .setDescription('Enter the amount of messages you want to delete.')
                .setRequired(true))
        .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
    async execute(interaction) {
        const amount = interaction.options.getNumber('amount');

        if (amount > 100) return interaction.reply('Put a number less than 100.');

        return await interaction.channel.bulkDelete(amount)
            .then( (messages) => interaction.reply(`Deleted ${messages.size} messages.`));
    }
};