0

I am trying to figure out what I am missing in the on_reaction_add(message) function to have the bot send a message when a user reacts to another player's message.

@client.listen()
async def on_message(message):
    """
    Looks for when a member calls 'bhwagon', and after 24 minutes, sends them a message
    :param message: the message sent by the user
    :return: a DM to the user letting them know their cooldown ended
    """
    if message.content.startswith("bhwagon") or message.content.startswith("missed wagon"):
        await cool_down_ended(message)
        await on_reaction_add(message)


@client.event
async def on_reaction_add(message):
    """
    Checks to see if there is a reaction on a message, and if there is, then send that user a message
    :param message: represents the context in which a command is being invoked under
    :return:
    """
    if message.emoji == '882814250710626405':  # If a certain reaction is used on a message
        await message.author.send("message")
yet-it-compiles
  • 108
  • 1
  • 10

1 Answers1

1

I see a few errors/things here that don't make sense to me.

  1. on_reaction_add has no message parameter, but depends on reaction and user.

  2. await message.author.send() would always send a message to the author of the message and not to the person who reacted, that does not work.

  3. Your given ID seems to be more of a message ID, but not a real emoji-ID.

Global emotes are usually built like this: <:NAME:ID - This is how it has to be specified in the code too.

Emojis from Discord can be copied easily.

IMPORTANT: All emojis must be preceded by \ to get either the name or the emoji to copy.

Based on my information now a new possible code:

@client.event
async def on_reaction_add(reaction, user): # reaction & user as an argument
    if reaction.emoji == '✅': # See if the reaction is the same as in the code
        await user.send("message") # Send the user who reacted a message

!! Please note that you also enable intents for this. Good contributions to this: Docs & Answer on StackOverflow !!

Dominik
  • 3,612
  • 2
  • 11
  • 44