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

[BUG] Paginator #185

Open
lamminade opened this issue Oct 18, 2019 · 2 comments
Open

[BUG] Paginator #185

lamminade opened this issue Oct 18, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@lamminade
Copy link
Contributor

Bug Description

Paginator has an error when called with empty item_list and display option 3 (Embed, list of strings).
The desired outcome with these input params would be that it displays an empty embed page, with the regular title and page 01 of 01 at the bottom.

Reproduction Steps

Call paginate with a Pages instance using display option 3 (Embed, list of strings), and an empty item_list.

p = Pages(ctx,
    item_list=[],
    display_option=(3,10))
p.paginate()

Potential Reasons behind Bug:

It seems to be crashing due to a discord-internal embed.to_dict call, as the pages_to_send variable is of type str, and when the internal call to_dict is made it throws the error as seen below.

In function organize_embeds_list the loop for populating the pages_to_send variable runs for i in range(page_counter), where page_counter is set on line 158 with math.ceil(len(self.itemList) / item_per_page). With the specified input params this obviously becomes zero, and thus the loop never runs, meaning the pages_to_send list is left empty and of type str.

Additional Context:

File "....local/share/virtualenvs/Canary-SrZpbO93/lib/python3.6/site-packages/discord/ext/commands/core.py", line 79, in wrapped ret = await coro(*args, **kwargs) File ".../Canary/cogs/info.py", line 66, in inrole await p.paginate() File ".../Canary/cogs/utils/paginator.py", line 247, in paginate await self._show_page(self.currentPage) File ".../Canary/cogs/utils/paginator.py", line 206, in _show_page embed=self.pagesToSend[self.currentPage], delete_after=300) File ".../.local/share/virtualenvs/Canary-SrZpbO93/lib/python3.6/site-packages/discord/abc.py", line 795, in send embed = embed.to_dict() AttributeError: 'str' object has no attribute 'to_dict'

@lamminade lamminade added the bug Something isn't working label Oct 18, 2019
@lamminade
Copy link
Contributor Author

Also, another thing I tried was calling paginator with items_per_page = 0 which, somewhat obviously, results in a division by 0 error

@davidlougheed
Copy link
Member

so maybe we should validate items_per_page at construction-time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants