I'm making a command that acts a manga reader, and I want to use wait_for
to wait for reactions from the user and then go forwards or backwards accordingly. However, I'm confused on how to implement it.
@commands.command()
async def read_manga(self, ctx, page=1):
page -= 1
image_urls = ['image1.url', 'image2.url', 'image3.url', 'etc.urls']
message = await ctx.send(image_urls[page])
def backward_check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) == '◀️'
def forward_check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) == '▶️'
try:
reaction, user = await self.bot.wait_for('reaction_add', timeout=60.0, check=forward_check)
except asyncio.TimeoutError:
print('Timed Out')
else:
await message.edit(content=image_urls[page+1])
try:
reaction, user = await self.bot.wait_for('reaction_add', timeout=60.0, check=backward_check)
except asyncio.TimeoutError:
print('Timed Out')
else:
await message.edit(content=image_urls[page-1])
As it is right now, the bot will only respond to the forward check and not the backward check. In addition, the bot will not detect if I react with ▶️, unreact, and then react with ▶️ again. How can I fix these issues?