【发布时间】:2021-05-25 08:20:57
【问题描述】:
所以我是 discord.py 的新手,我对 Lua(另一种编码语言)有一点经验。我试图让我的机器人在等待十分钟后重复它所做的事情。但是错误告诉我没有定义“重复”。我知道定义重复是什么,但我不知道要定义什么或导入什么。我的代码如下所示。
@bot.event
async def on_reaction_add(reaction, user):
emoji = reaction.emoji
if user.bot:
return
if emoji == '1️⃣':
await user.send('Reminding you every ten minutes.')
await asyncio.sleep(600)
await user.send('Reminding you to stop procrastinating!')
repeat()
应该发生什么:
当用户以"1️⃣" 对消息做出反应时(我没有显示消息代码,因为它没有问题),我的机器人会 DM 用户说“每十分钟提醒你一次”。然后,机器人将等待十分钟,然后再次向用户发送 DM,说“提醒您停止拖延!”除非用户说“pp!remove”,否则它将重复该过程。我只是无法使重复功能正常工作。
在此先感谢您。 :)
【问题讨论】:
-
如何调用未定义的函数?
-
尝试使用while循环或递归
标签: python discord discord.py