Polarcraft/discord-bot/commands/clear.js

25 lines
892 B
JavaScript
Raw Normal View History

2022-12-22 14:09:11 +01:00
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('clear')
.setDescription('Clear 1-100 messages')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addNumberOption(option => option
.setName('amount')
.setDescription('The amount of messages to clear')
.setRequired(true)),
async execute({ interaction, createEmbed, client }) {
const amount = interaction.options.getNumber('amount');
if (amount < 1 || amount > 100) return await interaction.reply({ embeds: [createEmbed.basic('The amount must be between 1-100')] });
const channel = client.channels.cache.get(interaction.channelId);
channel.bulkDelete(amount);
await interaction.reply({ embeds: [createEmbed.basic(`Cleared **${amount}** messages`)], ephemeral: true });
},
};