'await command error, i don't know how to fix it [closed]

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.environ['TOKEN'])

I tried to "fix" the await command but when i did that it said that message was unidentified and I'm very confused how to do it.



Solution 1:[1]

Fix your indentation and message should not be a string, its a parameter. Also there were unnecessary backslashes in client.run()

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.environ['TOKEN'])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1