From 4c305ed96c229c0caee77ac12b6fae7d3cd507e2 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Mon, 15 Jan 2024 16:34:41 -0600 Subject: [PATCH 1/5] fix(pages): Stop Default Buttons Reappearing On Page Change) --- discord/ext/pages/pagination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index 6228158c63..658af3de1f 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -569,7 +569,7 @@ async def update( self.buttons = {} for button in custom_buttons: self.add_button(button) - else: + elif self.use_default_buttons: self.buttons = {} self.add_default_buttons() From 74e34006ec59115b763c33fde5428a904afc306b Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Mon, 15 Jan 2024 16:56:45 -0600 Subject: [PATCH 2/5] chore: Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 207ed085ba..57ff127a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,7 @@ These changes are available on the `master` branch, but have not yet been releas ### Fixed +- Fixed `self.use_default_buttons` being assumed truthy by `Paginator.update` - Fixed `AttributeError` caused by [#1957](https://github.com/Pycord-Development/pycord/pull/1957) when using listeners in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989)) From ac57873e9b22b6ab2d4fbefd2569a04ee3bc8997 Mon Sep 17 00:00:00 2001 From: Icebluewolf <44532864+Icebluewolf@users.noreply.github.com> Date: Tue, 16 Jan 2024 07:38:59 -0600 Subject: [PATCH 3/5] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ff127a5b..02f8a477ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,7 +128,6 @@ These changes are available on the `master` branch, but have not yet been releas ### Fixed -- Fixed `self.use_default_buttons` being assumed truthy by `Paginator.update` - Fixed `AttributeError` caused by [#1957](https://github.com/Pycord-Development/pycord/pull/1957) when using listeners in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989)) @@ -210,6 +209,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2301](https://github.com/Pycord-Development/pycord/pull/2301)) - Fixed `AttributeError` caused by `command.cog` being `MISSING`. ([#2303](https://github.com/Pycord-Development/pycord/issues/2303)) +- Fixed `self.use_default_buttons` being assumed truthy by `Paginator.update`. + ([#2319](https://github.com/Pycord-Development/pycord/pull/2319)) ## [2.4.1] - 2023-03-20 From 16a87160cd097168dbf96a87f75b74e3ad2f1646 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Tue, 23 Jan 2024 07:29:52 -0600 Subject: [PATCH 4/5] fix(pages): Account for all combanations of default and custom buttons --- discord/ext/pages/pagination.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index 658af3de1f..c5f0724938 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -560,18 +560,18 @@ async def update( self.loop_pages = loop_pages if loop_pages is not None else self.loop_pages self.custom_view: discord.ui.View = None if custom_view is None else custom_view self.timeout: float = timeout if timeout is not None else self.timeout + self.custom_buttons = custom_buttons if custom_buttons is not None else self.custom_buttons self.trigger_on_display = ( trigger_on_display if trigger_on_display is not None else self.trigger_on_display ) - if custom_buttons and not self.use_default_buttons: - self.buttons = {} - for button in custom_buttons: - self.add_button(button) - elif self.use_default_buttons: - self.buttons = {} + self.buttons = {} + if self.use_default_buttons: self.add_default_buttons() + elif self.custom_buttons: + for button in self.custom_buttons: + self.add_button(button) await self.goto_page(self.current_page, interaction=interaction) @@ -679,9 +679,12 @@ async def goto_page( self.update_buttons() self.current_page = page_number if self.show_indicator: - self.buttons["page_indicator"][ - "object" - ].label = f"{self.current_page + 1}/{self.page_count + 1}" + try: + self.buttons["page_indicator"][ + "object" + ].label = f"{self.current_page + 1}/{self.page_count + 1}" + except KeyError: + pass page = self.pages[page_number] page = self.get_page_content(page) @@ -843,9 +846,12 @@ def update_buttons(self) -> dict: button["object"].label = button["label"] self.clear_items() if self.show_indicator: - self.buttons["page_indicator"][ - "object" - ].label = f"{self.current_page + 1}/{self.page_count + 1}" + try: + self.buttons["page_indicator"][ + "object" + ].label = f"{self.current_page + 1}/{self.page_count + 1}" + except KeyError: + pass for key, button in self.buttons.items(): if key != "page_indicator": if button["hidden"]: From bbe149cf94c61294a2664256c94403bb3eebf5b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:33:11 +0000 Subject: [PATCH 5/5] style(pre-commit): auto fixes from pre-commit.com hooks --- discord/ext/pages/pagination.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index c5f0724938..f9f08b965f 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -560,7 +560,9 @@ async def update( self.loop_pages = loop_pages if loop_pages is not None else self.loop_pages self.custom_view: discord.ui.View = None if custom_view is None else custom_view self.timeout: float = timeout if timeout is not None else self.timeout - self.custom_buttons = custom_buttons if custom_buttons is not None else self.custom_buttons + self.custom_buttons = ( + custom_buttons if custom_buttons is not None else self.custom_buttons + ) self.trigger_on_display = ( trigger_on_display if trigger_on_display is not None