Q
Q
Qweez2020-08-05 22:46:09
Python
Qweez, 2020-08-05 22:46:09

How to respond to the user's reaction?

@bot.command()
async def test(ctx):
  accept_decline = await ctx.send('Test')
  await accept_decline.add_reaction('one')
  await accept_decline.add_reaction('two')
  await accept_decline.add_reaction('three')
  await accept_decline.add_reaction('four')
  await accept_decline.add_reaction('five')
  await accept_decline.add_reaction('six')

Here is the code. When the user adds the "one" reaction, the bot needs to write a message.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-08-05
@Qweez

bot.wait_for("reaction_add"): https://discordpy.readthedocs.io/en/v1.3.4/api.htm...

@bot.command(ctx):
async def test(ctx):
    accept_decline = await ctx.send('Test')
    await accept_decline.add_reaction('one')
    try:
        reaction = await bot.wait_for("reaction_add", timeout=60, check = lambda r, u: r=='one' )
    except asyncio.TimeoutError:
        await channel.send("\N{THUMBS DOWN SIGN}")
    else:
        await channel.send("\N{THUMBS UP SIGN}")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question