robertwayne / dpymenus

Simplified menus for discord.py developers.
https://dpymenus.com/
MIT License
26 stars 4 forks source link

Pass list object to .add_pages() #30

Closed ghost closed 3 years ago

ghost commented 3 years ago

If I create a menu as follows:

        menu = PaginatedMenu(ctx)
        page_list = list()
        for x in userinfo:
            embed = Page(title="Moderator Action", color=14104292)
            embed.add_field(name="Type", value=x["Action"])
            embed.add_field(name="Moderator", value=x["Moderator"])
            embed.add_field(name="Reason", value=x["Reason"])
            page_list.append(embed)

        menu.add_pages(page_list)
        await menu.open()

and attempt to open it, I am given the result of ERROR:root:There must be more than one page in a menu. Expected at least 2, found 1.

Can I not pass a list object to the .add_pages() function, and if so - why not? Is this desirable behavior, or is it an unintended effect?

If I cannot pass a list object, would it be possible for this functionality to be implemented?

robertwayne commented 3 years ago

It can take a list object. I'm assuming userinfo only contains one element, thus is only generating a list with a single page -- which was originally an unintended way to construct a menu. The original thought process being it isn't really a menu if it only has a single page.

That said, this issue has come up a few times now so I think I consider it a flaw rather than a safety feature -- because a single page should be representable in a dynamically generated menu.

I am going to look at removing or changing this validation check.

ghost commented 3 years ago

I am going to look at removing or changing this validation check.

All right! Thank you, that makes things a lot easier!

robertwayne commented 3 years ago

This is fixed as of the most recent release (#31).