Secretcode
Secretcode

Reputation: 5

Reaction Bot DM discord.py

How would I go about having a discord bot in python send a dm to a user when the user reacts to a message with a checkmark. Like, let's say I have my bot in python send a message and when the user reacts to it it will send a dm to that user with info.

Example image

This is the code I was able to build which I guess is how it would work obviously it's not python syntax. Thanks!

if user.reaction == ✅:

    member.send("Nice to know you checked the message thanks")

Upvotes: 0

Views: 367

Answers (1)

Wasi Master
Wasi Master

Reputation: 1207

You can achieve this using the on_reaction_add or the on_raw_reaction_add. The latter is better since it does not rely on the bot's message cache

@bot.event
async def on_raw_reaction_add(payload):
    if payload.emoji == "\u2705" and reaction.message_id == 123:
        await payload.member.send("Hey")

This uses the raw event because the normal event only works if the message is in the bot's cache, which requires the message to be sent after the bot starts. \u2705 is the code of the ✅, you can also just use ✅ instead. 123 is just an example message-id, you can change it to anything you want. payload.member may be None under some circumstances so you also may wanna check for that

Upvotes: 1

Related Questions