mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
let hasPerms = require('../helpers.js').hasPerms;
|
|
let inPrivate = require('../helpers.js').inPrivate;
|
|
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 (inPrivate(msg)) {
|
|
msg.channel.send("You Cant Purge Message In DM's!");
|
|
return;
|
|
}
|
|
if (hasPerms(msg)) {
|
|
let newamount = 0;
|
|
if (!suffix) {
|
|
newamount = 2;
|
|
} else {
|
|
let amount = Number(suffix);
|
|
let adding = 1;
|
|
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. \n Total messages deleted including command: ' + 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!').then(message => message.delete(5000));
|
|
}
|
|
}
|
|
};
|