I get a syntax error when I try to send a discord message

Telepathic_Squid

I cannot run the program and I just get a syntax error. I am trying to send a message to a specific channel, but the ch variable for some reason lights up red. I am new to this, and I am not very good.

ch = client.get_channel(12345642256905728)
await ch.send('hello')
bguerra

In order to use "await", you have to use it inside of an asynchronous function. So you could so something like this:

async def sendMessage(message):
    ch = client.get_channel(12345642256905728)
    await ch.send(str(message))

The "str(message)" is just a safety precaution since you need to send a string when using ch.send().

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive