Browse Source

Add bulkDelete command to test

master
Abheek Dhawan 4 years ago
parent
commit
030cd7e7de
  1. 25
      index.js

25
index.js

@ -12,11 +12,36 @@ client.on("message", message => {
case '$score':
startScoring(message);
break;
case '$bulkdelete':
bulkDelete(message);
break;
default:
return;
}
});
async function bulkDelete(message) {
const args = message.content.split(' ').slice(1);
const amount = args.join(' ');
if (!amount) {
message.reply('please add the number of messages to be deleted!');
return;
}
if (!Number.isInteger(amount)) {
message.reply('the number is not an integer!');
}
if (amount > 250 && amount < 1) {
message.reply('the number is too large! It must be between 1 and 250 inclusive.');
}
await message.channel.fetch( { limit: amount } ).then(messages => {
message.channel.bulkDelete(messages).catch(console.error);
}).catch(console.error);
}
async function startScoring(message) {
let scoreA = 0;
let scoreB = 0;

Loading…
Cancel
Save