-1

if(command === clear){ const amount = arg.join(" ");

    if(!amount) return message.reply('please provide an amount of messages for me to delete')

    if(amount > 100) return message.reply(`you cannot clear more than 100 messages at once`)

    if(amount < 1) return message.reply(`you need to delete at least one message`)

    await message.channel.messages.fetch({limit: amount}).then(messages => {
        message.channel.bulkDelete(messages
)});
1
  • You must be missing 'async' keyword in function. One can write async keyword without await but reverse is not allowed. Just add async in function definition, this should fix. const handleSubmit = async (e) => { /*rest of the code*/} Commented Nov 3, 2020 at 10:34

1 Answer 1

0

Using await without an async declaration is not allowed. Please add the async keyword to your function. That should fix it.

Example:

If this code is under the message event, the code should be (or in arrow operator functions):

client.on('message', async message => {
    //code here
})

If this code is under a normal function:

async function newFunc(){
    //code here
}

Please remember for future reference that the mentioned error is thrown in this situation

Hope this helped.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.