Skip to content Skip to sidebar Skip to footer

How Do You Check If A Specific User Reacts To A Specific Message [discord.py]

I've looked at similar questions but none of the answers worked for me. I'm working on a bot where you type in (prefix)suggest (suggestion) and then it sends a message asking if yo

Solution 1:

To make it reaction check message specific you need to use reaction.message == message in the check function.

Here's the full example based on Libby's answer.

message = await ctx.send("Are you sure you want to submit this suggestion?")
await message.add_reaction("✅")
confirmation = await bot.wait_for("reaction_add", check=check) 
channel = bot.get_channel(channel_id) # Put suggestion channel ID here.defcheck(reaction, user):
    return user == ctx.author andstr(reaction.emoji) in ["✅"] and reaction.message == message

if confirmation:
    await channel.send(suggestion)

Solution 2:

You can use the wait_for function to make the bot wait until the author reacts with the checkmark.

First, do a check to ensure that the bot sends the suggestion to the suggestion channel only if the message author reacts with a checkmark:

defcheck(reaction, user):
    return user == ctx.author andstr(reaction.emoji) in ["✅"]

Then put the code that sends the confirmation message and has the wait_for function:

message = await ctx.send("Are you sure you want to submit this suggestion?")
await message.add_reaction("✅")
confirmation = await bot.wait_for("reaction_add", check=check) 
channel = bot.get_channel(channel_id) # Put suggestion channel ID here.

Finally, put the code that tells the bot what to do once the message author reacts:

if confirmation:
    await channel.send(suggestion)

Post a Comment for "How Do You Check If A Specific User Reacts To A Specific Message [discord.py]"