Reputation: 31
I've been looking for this code to get to work:
...
message = await ctx.send(embed=embed)
await message.add_reaction(":arrow_left:")
await message.add_reaction(":arrow_right:")
async def on_reaction(reaction, user):
if user.reaction.emoji == ":arrow_left:":
await message.edit("Page left")
if user.reaction.emoji == ":arrow_right:":
await message.edit("Page right")
Basically the bot reacts to its' own embed message. And I want let it edit the embed when clicking on the reaction that the bot added. That's where I want to use the temporary "on_reaction" in order to make it only work for this embed message.
Yours truly
Upvotes: 0
Views: 193
Reputation: 3592
You can use DiscordUtils
and work with the built-in paginator.
Here is a simple example:
import DiscordUtils as DiscordUtils
embed1 = discord.Embed(color = ctx.author.color, title="Test") # Add anything you want to
embed2 = [...]
embed3 = [...]
paginator = DiscordUtils.Pagination.CustomEmbedPaginator(ctx, remove_reactions=True)
paginator.add_reaction('⏮️', "first")
paginator.add_reaction('⏪', "back")
paginator.add_reaction('⏩', "next")
paginator.add_reaction('⏭️', "last")
paginator.add_reaction('🔐', "lock")
embeds = [embed1, embed2, embed3]
await paginator.run(embeds)
For more information see: DiscordUtils
Upvotes: 1