Hi I’m not sure what I did wrong? I’m following a yt video on how to code using python. But it keeps saying an error with synx or something.
await
needs to be within an async function so it would look something like:
import discord
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!hello'):
await message.channel.send('Hello!')
client.run('YOUR_BOT_TOKEN_HERE')
All I’ve done is add some indents before the:
if message.content.startswith('!hello'):
await message.channel.send('Hello!')
This means they are not inside the async
function.
1 Like
python allows async/await too? I thought only javascript did.
Python does have it. Since when I do not know. All I know it has existed for the past few weeks since its in code that old
1 Like
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.