繁体   English   中英

如何在 discord.py 中发送没有@client.event 的消息?

[英]How to send message without @client.event in discord.py?

我需要一种方法来不断检查 discord.py 中的消息'kill' 。我的代码中有很多 while 循环,所以我需要使用线程模块创建一个新线程。 如何在没有事件的情况下将消息发送到具有该线程的通道。

您可以使用asyncio.get_event_loop().create_task(channel.send("example message")) 像这样使用它:

import asyncio

client = discord.Client()

def funct():
    channel = client.get_channel(channel_id)
    asyncio.get_event_loop().create_task(channel.send("example message"))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM