/clear no longer deletes pinned messages

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

View File

@ -15,8 +15,15 @@ module.exports = {
)
.setDescription('Supprimer un grand nombre de messages d\'un salon'),
async execute(interaction, client) {
const number = interaction.options.getInteger('nombre');
await interaction.channel.bulkDelete(number);
await interaction.reply({ content: `J'ai bien supprimé ${number} message${number>1 ? "s" : ""} dans ce salon`, ephemeral: true});
const number = interaction.options.getInteger('nombre');
try {
const fetched = await interaction.channel.fetchMessages({ 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});
} catch(err) {
console.error(err);
}
}
};
};