From 459446526602d35af9cec596b552cddeeac4c992 Mon Sep 17 00:00:00 2001 From: Sepp J Morris Date: Mon, 12 Oct 2020 00:34:48 +0200 Subject: [PATCH] added an purge example - Update examples.js --- zoizbot/commands/examples.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/zoizbot/commands/examples.js b/zoizbot/commands/examples.js index 03fe188..8f38e8a 100644 --- a/zoizbot/commands/examples.js +++ b/zoizbot/commands/examples.js @@ -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 });