mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
let hasPerms = require('../helpers.js').hasPerms;
|
|
|
|
exports.commands = [
|
|
"purge" // command that is in this file, every command needs it own export as shown below
|
|
]
|
|
|
|
exports.purge = {
|
|
usage: "<number of messages>",
|
|
description: 'Deletes Messages',
|
|
process: function(bot,msg,suffix){
|
|
if (hasPerms(msg) === true ) {
|
|
if (!suffix) {
|
|
var newamount = "2"
|
|
} else {
|
|
var amount = Number(suffix)
|
|
var adding = 1
|
|
var newamount = amount + adding
|
|
}
|
|
let messagecount = newamount.toString();
|
|
msg.channel.fetchMessages({limit: messagecount})
|
|
.then(messages => {
|
|
msg.channel.bulkDelete(messages);
|
|
// Logging the number of messages deleted on both the channel and console.
|
|
msg.channel
|
|
.send("Deletion of messages successful. Total messages deleted: "+ newamount)
|
|
.then(message => message.delete(5000));
|
|
console.log('Deletion of messages successful. \n Total messages deleted including command: '+ newamount)
|
|
})
|
|
.catch(err => {
|
|
console.log('Error while doing Bulk Delete');
|
|
console.log(err);
|
|
});
|
|
} else {
|
|
msg.channel.send('only moderators can use this command!')
|
|
}
|
|
}
|
|
}
|