added an purge example - Update examples.js

This commit is contained in:
2020-10-12 00:34:48 +02:00
parent b4b4b59602
commit 4594465266

View File

@@ -57,6 +57,19 @@ zoizbot.on("message", async message => {
return message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${banReason}`)
}
//simple purge example command
if (command === "purge") {
const deleteCount = parseInt(args[0], 10);
if (!deleteCount || deleteCount < 2 || deleteCount > 100)
return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
const fetched = await message.channel.messages.fetch({ limit: deleteCount });
message.channel.bulkDelete(fetched)
.catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
}
else return
});