// prune.js - Discord bot message pruning command // Copyright (C) 2025 Luis Bauza // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js'; export default { data: new SlashCommandBuilder() .setName('prune') .setDescription('Prune up to 99 messages.') .addIntegerOption(option => option .setName('amount') .setDescription('Number of messages to prune') .setMinValue(1) .setMaxValue(99) .setRequired(true), ) .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), async execute(interaction) { const amount = interaction.options.getInteger('amount'); try { const deleted = await interaction.channel.bulkDelete(amount, true); await interaction.reply({ content: `Successfully deleted ${deleted.size} message(s).`, ephemeral: true, }); } catch (error) { console.error(error); await interaction.reply({ content: 'There was an error trying to prune messages in this channel!', ephemeral: true, }); } }, };