I'm trying to make a button / reaction to go back and forth between 3 different images, but the button is not coming back in the previous image, just advancing to the next one, could anyone help me?
if message.content.startswith('!image'):
msg1 = await Bot.send_file(message.channel, 'image1.png')
toReact = ('⏩')
for reaction in toReact:
await Bot.add_reaction(msg1, reaction)
def checkReaction(reaction, user):
e = str(reaction.emoji)
return e.startswith('⏩')
res = await Bot.wait_for_reaction(message=msg1, user=message.author, timeout=30, check=checkReaction)
if res is None:
await Bot.delete_message(msg1)
elif '⏩' in str(res.reaction.emoji):
await Bot.delete_message(msg1)
msg2 = await Bot.send_file(message.channel, 'image2.png')
toReact = ['⏪', '⏩']
for reaction in toReact:
await Bot.add_reaction(msg2, reaction)
def checkReaction2(reaction, user):
e = str(reaction.emoji)
return e.startswith('⏪','⏩')
res2 = await Bot.wait_for_reaction(message=msg2, user=message.author, timeout=30, check=checkReaction2)
if res2 is None:
await Bot.delete_message(msg2)
elif '⏩' in str(res.reaction.emoji):
await Bot.delete_message(mensagem2)
await Bot.send_file(message.channel, 'image3.png')
Here's what I came up with.
Basically, we have a loop that checks every reaction against the ones we want, and then delete the old message and send the new one if we see one of the reactions we're looking for.
Someone asked for a version that edits the message instead of sending a new one, I've also updated it to the latest version: