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 });
  },
};
