#๐Ÿ”’ Tracking reactions with discord.py

12 messages ยท Page 1 of 1 (latest)

wary plover
#

Hi everyone ! I'm new here and looking for help on my discord bot.
I'm working since 2 months on a discord bot to help managing my discord server (a discord for civilization VI players).
I have a command $mapvote that send some messages on the current channel and add reactions to help peoples to vote for the map settings for their games (see screenshot 1 under this post).
I want to make a new version of this command, the idea would be to detect the result of the votes and edit the message to show the result of the vote.
For example, if there are 7 players in the game, and the Pangaea reaction (๐ŸŒ‹) has been select 4 times, the MAP message is edited to display "Pangaea ๐ŸŒ‹ ".
I know it's probably not so hard to make, but I'm kinda new in coding. Does anyone has an idea ?

My main problem is tracking the reactions and use them for logic operations.

You can find the code on this GitHub Repository : https://github.com/Matezzi777/Civ-Private-Bot
Thanks !

empty relicBOT
#

@wary plover

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

wary plover
#

Screenshot 1

winged mesa
#

when do you want the message edit to happen

#

!d discord.ext.commands.Bot.wait_for

empty relicBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError) for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple) containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
wary plover
# winged mesa when do you want the message edit to happen

I want the edit to happen when one of the options has been selected by the majority of the players.

But my problem is, I don't want to wait for the result of the vote to continue the function. (No need to wait for the MAP to be voted before to send the BCY,... messages)

winged mesa
#

have you tried anything?

#

you can wait after all messages are sent

#

and keep a reference to all the messages sent

empty relicBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.