Search code examples
pythonpaginationdiscordbotsdiscord.py

Discord.py pagination


So i want to make embeds be paginated so it can change upon reacting to an emoji i found a project called disputils which made the process a lot easier, but it supports texts and is there anyway i can include pictures in this code(the documentation has no examples or says that pictures can be embedded any help would be appreciated):

@bot.command()
async def paginate(ctx):
    embeds = [
        Embed(title="test page 1", description="This is just some test content!", color=0x115599),
        Embed(title="test page 2", description="Nothing interesting here.", color=0x5599ff),
        Embed(title="test page 3", description="Why are you still here?", color=0x191638)
    ]

    paginator = BotEmbedPaginator(ctx, embeds)
    await paginator.run()

i also have tried to use embed.set_image but i get an error positional argument follows keyword argument (<unknown>, line 12)(it highlights the embed.set_image)


Solution

  • Try using Embed.set_image on a separate variable and then including that variable on the list of embeds:

    @bot.command()
    async def paginate(ctx):
        e = Embed(title="test page 1", description="foo", color=0x115599)
        e.set_image(url="foo.png")
        
        embeds = [
            e,
            Embed(title="test page 2", description="bar", color=0x5599ff)
        ]
    
        paginator = BotEmbedPaginator(ctx, embeds)
        await paginator.run()