Problem with discord bot

This is the code:
import discord
import os

client = discord.Client()

@client.event
async def on_ready():
print(‘We have logged in as {0.user}’.format(client))

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith(’$hello’):
await message.channel.send (‘Hi!’)

client.run(os.getenv(‘TOKEN’))
when i run it it says :SyntaxError: ‘await’ outside function

Hey, maybe you can use syntax highlighting and format the code properly using-
```py
print(“this is some code”)
```
This gets rendered as-

print("this is some code")

Formatting it might help us in helping you figure out the error.
I guess the issue here is that the await message.channel.send (‘Hi!’) isn’t inside the on_message function block. There should be 2 indents there

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