Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support format_page returning list of embeds #31

Merged
merged 5 commits into from
Jan 31, 2022

Conversation

DenverCoder1
Copy link
Collaborator

@DenverCoder1 DenverCoder1 commented Jan 28, 2022

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

@DenverCoder1 DenverCoder1 merged commit 2d1b124 into nextcord:master Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow format_page to return a list of embeds for interaction response
1 participant