Rizonn
Rizonn

Reputation: 25

Reaction Listener in discord.py

Okay, so I would like to make some kind of listener/watcher(?), that would track amount of reactions added to message. Should I make it as an async function (asyncio task?) or maybe there is better and more simple(?) solution. I would like it to track those reactions until specific amount of them. Would really appreciate any advice.

Upvotes: 1

Views: 1028

Answers (1)

Richard Snider
Richard Snider

Reputation: 26

Put something to this effect in your code. It will fire whenever a reaction is added while the bot is running.

@bot.listen()
async def on_reaction_add(reaction, user):
    # do something with reaction and user

or, if you're using discord.Client,

@client.event
async def on_reaction_add(reaction, user):
    # do something with reaction and user

I recommend looking at the documentation, which I will link, to see what things you can do with this, but to give you a head start, you can get the message itself using reaction.message and from there (since you mentioned counting reactions) get the full list of reactions with reaction.message.reactions.

on_reaction_add documentation
Reaction documentation
Message documentation

Upvotes: 1

Related Questions