K
K
Kirill Bely2020-11-11 14:38:08
Node.js
Kirill Bely, 2020-11-11 14:38:08

What is wrong with these lines?

const messageArray = message.content.split(' ');
const args = messageArray.slice(1);

robot.on("message", message => {
  if (!message.member.permissions.has("MANAGE_MESSAGES")) return message.channel.send('Lack of Perms!');
    
    let deleteAmount;

    if (isNaN(args[0]) || parseInt(args[0]) <= 0) { return message.reply('Please put a number only!') }

    if (parseInt(args[0]) > 100) {
        return message.reply('You can only delete 100 messages at a time!')
    } else {
        deleteAmount = parseInt(args[0]);
    }

    message.channel.bulkDelete(deleteAmount + 1, true);
    message.reply(`**Successfully** Deleted ***${deleteAmount}*** Messages.`)
})


In the console it displays the error "messageArray is not defined". What's wrong? It seems that he designated a constant for an array

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question