From cdc4b65e582320b13b14a7f438f263cff573bd98 Mon Sep 17 00:00:00 2001 From: DefiDebauchery <75273961+DefiDebauchery@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:13:36 -0400 Subject: [PATCH 1/2] Add current_page parameter to paginator.update() Signed-off-by: DefiDebauchery <75273961+DefiDebauchery@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/ext/pages/pagination.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 674fee9e46..2de68efacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index 463992988b..02c54adf6d 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -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. @@ -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) @@ -527,7 +530,9 @@ 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 From a898e7285f02e4e672f1f31a4463c1738e46d504 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 03:22:00 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- discord/ext/pages/pagination.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index 02c54adf6d..6228158c63 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -530,9 +530,7 @@ async def update( self.page_groups[self.default_page_group] ) self.page_count = max(len(self.pages) - 1, 0) - self.current_page = ( - current_page if current_page <= self.page_count else 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