Я собирал своего бота Discord и у меня возникли проблемы! мое массовое удаление работает, но только для cmd, который вы вводите больше, чем это, я получаю эту ошибку
(node:146828) DeprecationWarning: Collection#find: pass a function instead
(node:146828) UnhandledPromiseRejectionWarning: ReferenceError: args is not defined
at purge (C:\Users\nevbw\Desktop\games\FBIBot\bot.js:29:13)
at Client.<anonymous> (C:\Users\nevbw\Desktop\games\FBIBot\bot.js:46:2)
at Client.emit (events.js:224:7)
at MessageCreateHandler.handle
client.on('message', message => {
if (message.content === 'L!delete') {
async function purge() {
message.delete();
if (!message.member.roles.find("name", "LOLI POLICE")) {
message.channel.send('You need the \`LOLI POLICE\` role to use this command.');
return;}
if (isNaN(args[0])) {
message.channel.send('Please use a number as your arguments. \n Usage: ' + `L!` + 'purge
<amount>');
return;
}
const fetched = await message.channel.fetchMessages({limit: args[0]})
console.log(fetched.size + ' messages found, deleting...');
// Deleting the messages
message.channel.bulkDelete(fetched)
.catch(error => message.channel.send(`Error: ${error}`));
it into the channel.
}
purge(); // Make sure this is inside the if(msg.startsWith)
}
});