【发布时间】:2020-10-08 03:16:12
【问题描述】:
我正在制作一个不和谐的机器人。
我的不和谐机器人做什么监听整个服务器的消息并实时打印。
但是,我还希望代码能够不断地从控制台接收我的输入,并将其打印到特定的服务器 ID 中。以下是我的代码:
@bot.event
async def on_message(message):
# Prints message
@bot.event
async def on_ready():
# Execute on-ready stuff
while True:
kb = input(">>>")
#Delivers the message into a certain channel
问题是在 while True 循环执行后,其他 on_message 函数停止工作。我见过其他类似的问题,但我不了解异步函数。
有人能告诉我如何连续接收输入并实时打印传入的消息吗?
【问题讨论】:
标签: python python-3.x python-asyncio discord.py