spacemanspiff2007 / PyArtNet

"Python wrappers for the Art-Net protocol to send DMX over Ethernet"
GNU General Public License v3.0
67 stars 13 forks source link

SyntaxError: 'await' outside function #11

Closed DiamondD1 closed 3 years ago

DiamondD1 commented 3 years ago

I'm kinda new to python and I'm trying to create a discord bot. this is my 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('hello')

  client.run(os.getenv('califrag'))

when I run it it keeps saying SyntaxError: 'await' outside function. I have NO IDEA what's causing, or how to fix it. Please help!

spacemanspiff2007 commented 3 years ago

if message.content.startswith('$hello'): await message.channel.send('hello')

this part has to be inside an async function. Your indentation does not match