EDIT:
The solution was to add an additional condition in the check function, I have posted the details in a follow-up answer.
Main Question:
I am new python and decided to learn it by creating a discord bot.
On user command, I was able to get the bot to send a message that can change pages on react following this design:
I want to make a multi-page help command using discord.py
I can change the pages of one message just fine, however, if the user calls the command multiple times, reacting to one of the bot sent messages change the pages for all messages that haven't timed out. What can I change in the code so that reacting to one message won't trigger page changes in the other ones?
Additional questions:
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"]
# This makes sure nobody except the command sender can interact with the "menu"
- I understand that wait_for will use this function as a check, but where and how are the check parameters being passed in? How could I add more parameters if possible?
reaction, user = await bot.wait_for("reaction_add", timeout=60, check=check)
- In the documentation, I couldn't pin down the return value of the wait_for method, it looks like it changes under different circumstances.
- We aren't passing in a message instance into the wait_for method, so how does the method know which message to wait for a reaction on?
- What happens to the flow of the program if the check fails? It appears that statements under this line are executed only if check() returns true. But what happens when the check fails?