-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
)});
  • 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*/} – Durgesh Nov 03 '20 at 10:34

1 Answers1

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.

Rak Laptudirm
  • 174
  • 2
  • 13