【发布时间】:2021-10-22 00:32:09
【问题描述】:
我有一个 Discord Bot 程序,当我调用函数时需要发送消息,但代码卡在 bot.loop.create_task。
下面是我的代码:
bot.py
async def send_msg(word):
global bot
await bot.wait_until_ready()
ch=bot.get_channel(channel)
print(ch)
await ch.send("The word "+word+" has been spoken :)")
def action(word):
bot.loop.create_task(send_msg(word))
send_msg.py
from bot import action
action(word)
【问题讨论】:
-
如果你想实际创建一个在不和谐中发送消息的函数(没有不和谐机器人,我不明白你为什么需要它)你可以看看我的@987654321 @
-
我会试试你的解决方案,非常感谢!
-
这行得通!!!!谢谢????
标签: python python-3.x discord discord.py python-asyncio