diff --git a/src/commands/clear/index.js b/src/commands/clear/index.js new file mode 100644 index 0000000..cd7a909 --- /dev/null +++ b/src/commands/clear/index.js @@ -0,0 +1,26 @@ +import { SlashCommandBuilder, EmbedBuilder, PermissionsBitField } from 'discord.js'; + +export default { + data: new SlashCommandBuilder() + .setName('clear') + .setDescription('Deletes chosen amount of messages') + .addIntegerOption((option) => { + option.setName('amount') + .setDescription('amount of messages to delete') + .setMinValue(1) + .setMaxValue(25) + .setRequired(true); + return option; + }) + .setDMPermission(false) + .setDefaultMemberPermissions(PermissionsBitField.Flags['Administrator']), + async execute(interaction, api) { + const amount = interaction.options.getInteger('amount'); + await interaction.channel.bulkDelete(amount); + + const embed = new EmbedBuilder() + .setTitle(`Deleted ${amount} messages in total`) + .setColor(interaction.member.displayColor); + await interaction.reply({ embeds: [ embed ] }); + } +};