From 392dd2c8804b3036e38a30b6790f2b0b9ca1de77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Thu, 6 Sep 2018 17:26:58 +0200 Subject: [PATCH] not working --- commands/purge | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 commands/purge diff --git a/commands/purge b/commands/purge new file mode 100644 index 00000000..16f84f93 --- /dev/null +++ b/commands/purge @@ -0,0 +1,22 @@ +exports.run = (client, message, args) => { + + const StaffRole = message.guild.roles.find("name", "Staff"); + if (!StaffRole) + return console.log("The Staff role does not exist"); + + if (!message.member.roles.has(StaffRole.id)) + return message.reply("Sick you thought"); + + if (!message.GuildMember.hasPermission()) + return message.reply(" "); + + const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2]) + if (!amount) return message.reply('Must specify an amount to delete!'); + message.channel.fetchMessages({ + limit: 100, + }).then((messages) => { + messages = messages.filter(m => m.author.id).array().slice(0, amount); + + message.channel.bulkDelete(messages).catch(error => console.log(error.stack)); + }) +} \ No newline at end of file