From facaf001ad622156674cca049116c57689f1bd97 Mon Sep 17 00:00:00 2001 From: Keanu Date: Thu, 13 Aug 2020 17:06:10 +0200 Subject: [PATCH] Added purge command to admin. --- src/commands/admin.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/commands/admin.ts b/src/commands/admin.ts index c693e1a..d113f83 100644 --- a/src/commands/admin.ts +++ b/src/commands/admin.ts @@ -87,6 +87,24 @@ export default new Command({ } } }) + }), + purge: new Command({ + description: "Purges bot messages.", + permission: Command.PERMISSIONS.BOT_SUPPORT, + async run($: CommonLibrary): Promise + { + $.message.delete(); + const msgs = await $.channel.messages.fetch({ + limit: 100 + }); + const travMessages = msgs.filter(m => m.author.id === $.client.user?.id); + + await $.message.channel.send(`Found ${travMessages.size} messages to delete.`) + .then(m => m.delete({ + timeout: 5000 + })); + await $.message.channel.bulkDelete(travMessages); + } }) } }); \ No newline at end of file