You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
895 B

module.exports = {
name: 'purge',
roles: ['732345527143759943'],
description: 'Purge the last few messages specified by the user!',
async execute(message,args) {
let fetched;
let amount = Number(message.content.split(" ")[1]);
if(!amount){
return message.channel.send("You must specify an amount to purge");
}
let deleted = 0;
let channel = message.channel;
let message_manager = channel.messages;
do {
let limit = 100;
if(amount - deleted < limit){
limit = amount - deleted;
}
fetched = await message_manager.fetch({ limit: limit });
channel.bulkDelete(fetched);
deleted += fetched.size
}
while(fetched.size >= 3 && deleted < amount);
let m = await message.channel.send("Done purging!")
}
}