@client.event
async def on_reaction_add(reaction, user):
print('reaction added')
当我添加 react 时,它似乎没有打印“已添加 react ”,我在机器人上线后添加了 react ,但仍然不起作用。 完整代码:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('logged on!')
@client.event
async def on_reaction_add(reaction, user):
print('reaction added')
client.run('token_here')
最佳答案
我认为您的问题来自于消息是在您的机器人启动之前发送的。正如 documentation 中所写:
If the message is not found in the internal message cache, then this event will not be called.
您应该使用on_raw_reaction_add
,即使消息不在内部缓存中(因此在机器人启动之前发送),它也可以工作。这将返回 payload包含 id 而不是对象(因此如有必要,请转换它们)。
希望能解决您的问题
关于python - 不和谐中的 on_reaction_add 似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59225084/