0
votes

I'm trying to implement a bot for a friend in which the "info" command would show a user's info on one embed page and the next would show any characters the user owns (read through gspread).

mx = await ctx.send(embed=contents[0])   
  await mx.add_reaction("◀")
  await mx.add_reaction("▶")

  def check(reaction, user):
    return user == ctx.author and str(reaction.emoji) in ["◀", "▶"]

  while True:
    try:
      reaction, user = await client.wait_for("reaction_add", timeout=20, check=check)
      if str(reaction.emoji) == "▶" and cur_page != pages:
        cur_page += 1
        await mx.edit(embed=contents[cur_page - 1])
        await mx.remove_reaction(reaction, user)
      elif str(reaction.emoji) == "◀" and cur_page > 1:
        cur_page -= 1
        await mx.edit(embed=contents[cur_page - 1])
        await mx.remove_reaction(reaction, user)
      else:
        await mx.remove_reaction(reaction, user)
    except asyncio.TimeoutError:
      await mx.clear_reaction("◀")
      await mx.clear_reaction("▶")
      break 

The problem is, whenever a user sends more than one info command, on reaction, it causes all of their messages that are still active to be edited, not just the one they're reacting on. I also tried:

def check(reaction, user):
    return user == ctx.author and str(reaction.emoji) in ["◀", "▶"]
    mx == reaction.message

But it didn't fix the problem. I also tried .json dumping and replacing the mx.id with the user's most recent message but this returned the same issue. Any help would be appreciated!

1

1 Answers

0
votes

mx == reaction.message should also be part of the return statement.

Fixed code:

def check(reaction, user):
    return user == ctx.author and str(reaction.emoji) in ["◀", "▶"] and mx == reaction.message