Error: SyntaxError: await is only valid in async function (index.js:32)

1 Like

Hi @Tomas_Tcaci,

What the error says is true; you can only await a call if the function you are in, is async.

You are in the scope of the callback function, (member) => {}

So try changing it to:

 client.on('guildMemberAdd', async (member) => {

Check out this code example:

I hope it helps :slight_smile:

I do this, but in console this error:

That error says that on line 38, message is not defined.

If you look at your code you will see this is correct – there is no message variable.

The purpose of line 38 is to get the guild.memberCount, so instead of message.guild.memberCount, try using member.guild.memberCount (line 29 tells us that member.guild does exist)

i Have a third error)

On line 76, instead of member.guilds.channels.find, replace it with member.guilds.channels.cache.find.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.