nextcord / nextcord-ext-menus

A nextcord menu and pagination extension that makes working with reaction menus and button component menus a bit easier
https://menus.docs.nextcord.dev
MIT License
26 stars 9 forks source link

feat: support format_page returning list of embeds #31

Closed DenverCoder1 closed 2 years ago

DenverCoder1 commented 2 years ago

Resolves #29

Previously a dict containing { "embeds": embeds } would have to be returned in format_page to send multiple embeds. This simplifies the usage by allowing the user to simply return the list of embeds.

Example:

class MultipleEmbeds(menus.ListPageSource):
    def __init__(self, data):
        super().__init__(data, per_page=3)

    async def format_page(self, menu, entries):
        embeds = []
        for entry in entries:
            embed = nextcord.Embed(title="Entries", description=entry)
            embeds.append(embed)
        return embeds

@bot.slash_command(guild_ids=[TESTING_GUILD_ID], name="beds")
async def button_multiple_embed_description(interaction):
    data = [f"Description for entry #{num}" for num in range(1, 51)]
    pages = menus.ButtonMenuPages(source=MultipleEmbeds(data))
    await pages.start(interaction=interaction)

image