Skip to content

Commit

Permalink
fix: AsyncIterator buttons not getting displayed (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenverCoder1 authored Dec 12, 2021
1 parent 8f8ddd4 commit 792eb11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nextcord/ext/menus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .utils import *

# Needed for the setup.py script
__version__ = "1.3.3"
__version__ = "1.3.4"
3 changes: 3 additions & 0 deletions nextcord/ext/menus/menu_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ async def start(
):
await self._source._prepare_once()
await super().start(ctx, channel=channel, wait=wait)
# If we're not paginating, we can remove the pagination buttons
if not self._source.is_paginating():
await self.clear()

async def show_checked_page(self, page_number: int):
max_pages = self._source.get_max_pages()
Expand Down
5 changes: 4 additions & 1 deletion nextcord/ext/menus/page_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@ async def prepare(self, *, _aiter=_aiter):

def is_paginating(self) -> bool:
""":class:`bool`: Whether pagination is required."""
return len(self._cache) > self.per_page
# If we have not prepared yet, we do not know if we are paginating, so we return True
# This is to ensure that the buttons will be created in the case we are paginating
# If we have prepared, but we are exhausted before 1 page, we are not paginating
return not self._cache or len(self._cache) > self.per_page

async def _get_single_page(self, page_number: int) -> DataType:
if page_number < 0:
Expand Down

0 comments on commit 792eb11

Please sign in to comment.