Skip to content
await error
Profile icon

hi. i am trying to make a discord chat bot.
when i put in “await”
there is this error appearing : Syntax Error : ‘await’ outside function

You are viewing a single comment. View All
Profile icon

Yup the problem is that you are using await outside of an async function. The last two lines should be like this:

@client.event async def on_message(msg): if == client.user: return if msg.startswith('hello'): await ctx.send('yo, whats good.')

I also made some necessary changes. And you should put the token in a .env file so that even if the repl is public you don't need to remove the token to show it to someone.