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

My discord bot gives an error when I try send a message

Is there a way to get rid of the syntax error when I run try and except?

When I try to kick someone on Discord using bot I get an error

I get this error when I try to install

When i try to run a discord bot it says that "message is not defined"

I get a syntax error when I try to use array map function in Google Scripts. Why?

Why did i get every time an Syntax error when i try to put an Variable in an Xpath

Why do I get a syntax error when I try to print a nested hash that has keys containing colons?

Can't get IWebSocketConnection open when I try to send a message to be displayed on a wicket WebPage

I get a syntax error when I import discord in the cmd but not in vs code

When I try to send data from one table to another, I get an error

When I try and run pyspark.cmd I get the error message "find: 'version': No such file or directory"

How do I get a better error message when I try to pip install with an incompatible python version?

I get an error message when i try to parse an XML response using REST assured

Why do I get an error message of NoneType object is not callable when I try to call this function?

Python/Terminal - Why am I getting this error message when I try to get user input

I´m having the error #1241 in MySql when I try this syntax

Whenever I try to compile javascript code I get a syntax error

Bot sends an empty message when I try to send a RichEmbed

How do I get my Discord bot to send a welcome message?

How can I get a discord bot to send a message if a command is said?

Why does audio.buffered.end(0) get an error message when I try to get buffered time

I cant send a message with a discord webhook using cURL error : "Cannot send an empty message

I get error message "runtime error: index out of range [0] with length 0" when I try to start minikube

I get the error when i try get 50% of the image with cropperJS

I get an error when i try apt-get update?

Syntax Error when I try to create trigger in mysql

Java is Throwing Syntax Error When I Try to Execute an SQL Query

syntax Error in PostgreSQL when I try to create Trigger