diff --git a/CHANGELOG.md b/CHANGELOG.md index 207ed085ba..02f8a477ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -209,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 diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py index 6228158c63..f9f08b965f 100644 --- a/discord/ext/pages/pagination.py +++ b/discord/ext/pages/pagination.py @@ -560,18 +560,20 @@ 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) - else: - 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 +681,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 +848,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"]: