2023-10-13 15:04:11 +02:00
|
|
|
import { SlashCommandBuilder } from "discord.js";
|
2022-11-09 14:44:05 +01:00
|
|
|
|
2023-09-13 21:12:45 +02:00
|
|
|
export default {
|
2023-10-13 15:04:11 +02:00
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName("clear")
|
|
|
|
.setDefaultMemberPermissions(0x2)
|
|
|
|
.addIntegerOption((option) =>
|
|
|
|
option
|
|
|
|
.setName("nombre")
|
|
|
|
.setDescription("Quantité de messages à supprimer")
|
|
|
|
.setMinValue(1)
|
|
|
|
.setMaxValue(100)
|
|
|
|
.setRequired(true),
|
|
|
|
)
|
|
|
|
.setDescription("Supprimer un grand nombre de messages d'un salon"),
|
|
|
|
async execute(interaction) {
|
|
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
const number = interaction.options.getInteger("nombre");
|
|
|
|
try {
|
|
|
|
const fetched = await interaction.channel.messages.fetch({
|
|
|
|
limit: number,
|
|
|
|
});
|
|
|
|
const notPinned = fetched.filter(
|
|
|
|
(fetchedMsg) => !fetchedMsg.pinned,
|
|
|
|
);
|
2023-08-29 22:40:42 +02:00
|
|
|
|
2023-10-13 15:04:11 +02:00
|
|
|
await interaction.channel.bulkDelete(notPinned, true);
|
|
|
|
await interaction.editReply({
|
|
|
|
content: `J'ai bien supprimé ${notPinned.size} message${
|
|
|
|
notPinned.size > 1 ? "s" : ""
|
|
|
|
} dans ce salon`,
|
|
|
|
ephemeral: true,
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
2023-09-30 08:29:50 +02:00
|
|
|
},
|
2023-08-29 22:40:42 +02:00
|
|
|
};
|