Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 4x 4x 1x 3x 1x 2x 1x 1x 4x | /**
* Remove a specified number of messages from the channel.
* @module prune
* @return {string | null} - message (as a message to discord text channel); no message sent if successful
*/
module.exports = {
name: 'prune',
description: 'Prune up to 99 messages.',
/**
* @method execute
* @param {string} message - command, used to determine which channel to return results
* @param {string} args - number of messages to remove (between 1 and 99)
* @return {string | null} any errors; null on success
*/
execute(message, args) {
/**
* @const {integer} amount
* @summary number of messages to remove
*/
const amount = parseInt(args[0]) + 1;
/**
* @function pruneChannel
* @param {integer} count - how many messages to delete
* @return {string | null} message if error, otherwise null
* @summary bulk delete the number of messages requested
*/
function pruneChannel(count) {
if (isNaN(count)) {
return message.reply('that doesn\'t seem to be a valid number.');
} else if (count <= 1 || count > 100) {
return message.reply('you need to input a number between 1 and 99.');
}
message.channel.bulkDelete(count, true).catch(err => {
console.error(err);
message.channel.send('there was an error trying to prune messages in this channel!');
});
}
pruneChannel(amount);
},
};
|