不和谐.py。如何在“on_raw_reaction_add”函数中等待人的反应?

时间:2021-07-04 15:34:42

标签: discord discord.py

我需要从他的私人频道获得用户的反应。这是正确的做法吗?

@bot.event
async def on_raw_reaction_add(payload):
    reactioneer = payload.member
    emoji = payload.emoji
    if emoji.name == "?":
        msg = await reactioneer.send("Hi! Which greeting would you like to hear every morning? Click the reaction of it. Hello - 1, Morning - 2...")
        await msg.add_reaction(:one:)
        await msg.add_reaction(:two:)
        def check(user, payload):
            return user == payload.member and message.channel.type == discord.ChannelType.private
        await bot.wait_for("payload", check = check)
        ### some things with data bases (does not matter now)
        await reactioneer.send("Alright, I will send this greeting every morning!")
       

1 个答案:

答案 0 :(得分:1)

await bot.wait_for("raw_reaction_add", check=check)

bot.wait_for() 等待 WebSocket event 被分派。