首页 > 解决方案 > on_raw_reaction_add() 每条消息只工作一次吗?

问题描述

所以我正在制作一个不和谐的机器人,其中机器人有一个列表,我希望用户能够做出反应来改变它。

到目前为止,这是我想出的。

@client.event
async def on_raw_reaction_add(payload):
    global msg
    global msg_id
    global list_of_embeds
    amount = 0
    if payload.message_id == msg_id:
        if payload.emoji.name == "➡️":
            await msg.edit(embed=list_of_embeds[amount])
            amount += 1

这只是我想要的真实代码的原型,但它不起作用。我第一次反应时它工作正常,但之后每次我不反应并再次反应时它都不会改变。msg 变量是包含消息的变量,msg_id 是包含消息 id 的变量,list_of_embeds 是包含我要发送的嵌入的列表。任何帮助,将不胜感激。

标签: pythondiscord.py

解决方案


推荐阅读