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: add current_page parameter to paginator.update() #1983

Merged
merged 2 commits into from Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#1940](https://github.com/Pycord-Development/pycord/pull/1940))
- Added support for text-related features in `StageChannel`.
([#1936](https://github.com/Pycord-Development/pycord/pull/1936))
- Added `current_page` argument to Paginator.update()
([#1983](https://github.com/Pycord-Development/pycord/pull/1983))

## [2.4.1] - 2023-03-20

Expand Down
5 changes: 4 additions & 1 deletion discord/ext/pages/pagination.py
Expand Up @@ -465,6 +465,7 @@ async def update(
custom_buttons: list[PaginatorButton] | None = None,
trigger_on_display: bool | None = None,
interaction: discord.Interaction | None = None,
current_page: int = 0,
):
"""Updates the existing :class:`Paginator` instance with the provided options.

Expand Down Expand Up @@ -505,6 +506,8 @@ async def update(
interaction: Optional[:class:`discord.Interaction`]
The interaction to use when updating the paginator. If not provided, the paginator will be updated
by using its stored :attr:`message` attribute instead.
current_page: :class:`int`
The initial page number to display when updating the paginator.
"""

# Update pages and reset current_page to 0 (default)
Expand All @@ -527,7 +530,7 @@ async def update(
self.page_groups[self.default_page_group]
)
self.page_count = max(len(self.pages) - 1, 0)
self.current_page = 0
self.current_page = current_page if current_page <= self.page_count else 0
# Apply config changes, if specified
self.show_disabled = (
show_disabled if show_disabled is not None else self.show_disabled
Expand Down