I need a way to constantly check for the message 'kill'
in discord.py. I have many while loops in my code so I need to create a new thread with the threading module. How can I send a message to a channel with that thread without the events.
You can use asyncio.get_event_loop().create_task(channel.send("example message"))
. Use it like this:
import asyncio
client = discord.Client()
def funct():
channel = client.get_channel(channel_id)
asyncio.get_event_loop().create_task(channel.send("example message"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.