#Done using Cogs
#Example of simple back/delete/next buttons using reactions
@commands.command(name="do_stuff")
async def show_stuff(self, ctx, *args):
message = await ctx.send("message") #stores message sent
#adds reactions and calls react_check()
await message.add_reaction("◀️")
await message.add_reaction("❌")
await message.add_reaction("▶️")
await self.react_check(ctx, message)
async def react_check(self, ctx, message):
# CHECK FUNCTION USED IN wait_for()
def check(reaction, user):
#checks if the author of the command reacted
#and if the reaction is in the message he called
return user == ctx.message.author and message.id == reaction.message.id
# WAITS FOR USER REACTION
try:
#returns a list with information once the author reacts
reaction_info = await self.bot.wait_for("reaction_add", check=check, timeout=60)
reaction = reaction_info[0] #gets just the emote
except asyncio.TimeoutError:
return #if user takes too long, stop working
# WORKS WITH THE AUTHOR REACTION
if str(reaction) == "❌":
await message.delete()
elif str(reaction) == "◀️":
#do stuff...
await message.remove_reaction(reaction, ctx.message.author) #remove reaction from the author
await self.react_check(ctx, message) #call the function again
#elif condition:
#do other stuff...
else: #if it's not an expected emote, calls the function again
await self.react_check(ctx, message)
#the function will keep being called until a TimeoutError occurs