【发布时间】:2020-06-07 11:45:55
【问题描述】:
我正在为不和谐制作一个机器人。和这个问题基本一样:How can I run an async function using the schedule library?
除了上面的链接没有任何效果。就我而言,我得到“从未等待过我的功能”
async def birthday():
channel = client.get_channel(xxxxxx)
fileName = open("birthdayFile.txt", "r")
today = time.strftime('%m%d')
for line in fileName:
if today in line:
line = line.split(' ')
line[-1] = line[-1].strip()
if line[-1] != line[1]:
bdayperson = line[1]+' '+line[2]
else:
bdayperson = line[1]
await channel.send(f"Happy Birthday to "+ bdayperson + "! ????????" )
schedule.every().day.at("18:36").do(client.loop.call_soon_threadsafe, birthday)
【问题讨论】:
-
您能否显示您尝试遵循other question 答案中的建议的代码?正如您自己指出的那样,这个问题是重复的,但也许可以改进另一个问题的答案,以更清楚地展示如何解决问题。
标签: python-3.x bots discord python-asyncio discord.py