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

fix(pages): default buttons reappearing on page change #2319

Merged
merged 5 commits into from
Jan 24, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 20 additions & 12 deletions discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"]:
Expand Down
Loading