Search code examples
discord.pyembed

Scrolling down in a discord.py embed


This is my embed rn

It uses the google API to get upcoming events on a calendar but I have to limit the number of events it gets since the message will be too long. The list of calendars is stored in the description of the embed. Is there any way to limit the embed to a certain size and be able to scroll down in the description so all events can be displayed?


Solution

  • As Zimano said, you can't have scrollable elements in embeds, but what you can do is a multi-page embed, the easiest approach would be with ext.menus (To install it: python -m pip install -U git+https://github.com/Rapptz/discord-ext-menus)

    import discord
    from discord.ext import menus
    
    class MultiPageEmbed(menus.ListPageSource):
        async def format_page(self, menu, entry):
            return entry
    
    
    @bot.command()
    async def whatever(ctx):
        # Put all your embeds here
        embeds = [discord.Embed(title="Embed 1"), discord.Embed(title="Embed 2"), discord.Embed(title="Embed 3")]
    
        menu = menus.MenuPages(MultiPageEmbed(embeds, per_page=1))
        await menu.start(ctx)
    

    Unfornatelly it's still in beta so there's no docs about it.