0

So I want to make a text game that edits the character every time the author who called the command reacts. My code so far for adding reactions:

@client.command()
async def test(ctx):
    msg = await ctx.send('Hi')
    up = '⬆'
    down = '⬇'
    left = '⬅'
    right = '➡'
    await msg.add_reaction(up)
    await msg.add_reaction(down)
    await msg.add_reaction(left)
    await msg.add_reaction(right)

This adds the up arrow, down arrow, left arrow, and right arrow to the message "Hi". I want to see if someone clicked on the arrow and if that someone is the author of the command. I have no idea how to get if the author of the command clicked on the arrow reaction. Any help would be appreciated.

Kromydas
  • 111
  • 3
  • 11

1 Answers1

1

If you're waiting for a reaction, use wait_for() with the reaction_add event as the positional argument.

To limit it to the invoker, you can create a check and pass it into the check kwarg of wait_for(). The check would take in two arguments and you only need to compare if ctx.author is the same as the check author.

There is an example for wait_for() in the documentation

References: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=wait_for#discord.ext.commands.Bot.wait_for

CubeBlazer
  • 124
  • 5
  • I am waiting for the author to click on the reaction the bot made, – Kromydas Nov 20 '20 at 19:35
  • You would still use the reaction_add event, you can limit who can use it in the check – CubeBlazer Nov 20 '20 at 19:37
  • but doesn't reaction_add wait for someone to add an reaction, not click on an reaction? – Kromydas Nov 20 '20 at 19:41
  • `reaction_add` waits for a reaction to be added. Clicking on a reaction is still adding a reaction because you're adding a react onto an existing reaction – CubeBlazer Nov 20 '20 at 19:48
  • Wait, how do you reset an reaction so everyone who clicked on it will be erased except for you? I know this isn't on the question, but it would be great if u helped! – Kromydas Nov 20 '20 at 19:58
  • You can reset reactions using [Message.clear_reactions()](https://discordpy.readthedocs.io/en/latest/api.html?highlight=clear#discord.Message.clear_reactions) then re-reacting on the bot. – CubeBlazer Nov 30 '20 at 03:38