Tony_I
Tony_I

Reputation: 87

Discord.py. How can I wait_for person's reaction inside "on_raw_reaction_add" function?

I need to get the reaction of the user from his private channel. Is this the right way to do that?

@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!")
       

Upvotes: 0

Views: 54

Answers (1)

schlöpp
schlöpp

Reputation: 191

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

bot.wait_for() waits for a WebSocket event to be dispatched.

Upvotes: 1

Related Questions