mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-30 08:51:30 +00:00
purge bot to delete messages
This commit is contained in:
parent
faf6fa6274
commit
a545a47bd2
1 changed files with 37 additions and 0 deletions
37
bot/modules/purge.js
Normal file
37
bot/modules/purge.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
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!')
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue