Update clear.js

This commit is contained in:
Ninjdai 2023-08-29 22:44:36 +02:00 committed by GitHub
parent 1348db4eb3
commit b4797d7487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,13 +15,14 @@ module.exports = {
)
.setDescription('Supprimer un grand nombre de messages d\'un salon'),
async execute(interaction, client) {
await interaction.deferReply({ ephemeral: true })
const number = interaction.options.getInteger('nombre');
try {
const fetched = await interaction.channel.fetchMessages({ limit: number });
const fetched = await interaction.channel.messages.fetch({ limit: number });
const notPinned = fetched.filter(fetchedMsg => !fetchedMsg.pinned);
await interaction.channel.bulkDelete(notPinned, true);
await interaction.reply({ content: `J'ai bien supprimé ${number} message${number>1 ? "s" : ""} dans ce salon`, ephemeral: true});
await interaction.editReply({ content: `J'ai bien supprimé ${number} message${number>1 ? "s" : ""} dans ce salon`, ephemeral: true});
} catch(err) {
console.error(err);
}