diff --git a/README.md b/README.md index c3320ca..5fbcfac 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ buttons) behind previous / jump / next navigation, with an optional cache button `requirements.txt`: ``` -dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.1 +dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.2 ``` Direct: ```bash -pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.1" +pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.2" ``` Requires `discord.py` (pulled transitively). diff --git a/pyproject.toml b/pyproject.toml index b6222a4..5d83596 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "dpy_paginator" -version = "0.1.1" +version = "0.1.2" description = "Button-navigated paginator for discord.py — config-free, injectable emojis, installable." requires-python = ">=3.10" dependencies = [ diff --git a/src/dpy_paginator/dpy_paginator.py b/src/dpy_paginator/dpy_paginator.py index cbe238a..ef12075 100644 --- a/src/dpy_paginator/dpy_paginator.py +++ b/src/dpy_paginator/dpy_paginator.py @@ -280,27 +280,34 @@ class ButtonPaginator(Generic[PageT_co], discord.ui.View): return self._page_kwargs - def update_buttons(self) -> None: - """rebuild the action row for the current page state""" + def update_buttons(self, nav: bool = True) -> None: + """rebuild the action row for the current page state + + nav=False rebuilds with only the page's custom buttons and no navigation + items (prev/jump/cache/next) — a single-page result that still carries + custom buttons keeps them (and their live callbacks) without a nav row. + """ self.clear_items() - self.previous_page.emoji = self.emojis["previous"] - self.previous_page.disabled = self.current_page <= 0 - self.add_item(self.previous_page) + if nav: + self.previous_page.emoji = self.emojis["previous"] + self.previous_page.disabled = self.current_page <= 0 + self.add_item(self.previous_page) - self.jump_button.label = self.page_text.format(self.current_page + 1, self.max_pages) - self.add_item(self.jump_button) + self.jump_button.label = self.page_text.format(self.current_page + 1, self.max_pages) + self.add_item(self.jump_button) for button in self.current_page_buttons: self.add_item(button) - if self.cache: - self.cache_button.emoji = self.emojis["cache"] - self.add_item(self.cache_button) + if nav: + if self.cache: + self.cache_button.emoji = self.emojis["cache"] + self.add_item(self.cache_button) - self.next_page.emoji = self.emojis["next"] - self.next_page.disabled = self.current_page >= self.max_pages - 1 - self.add_item(self.next_page) + self.next_page.emoji = self.emojis["next"] + self.next_page.disabled = self.current_page >= self.max_pages - 1 + self.add_item(self.next_page) async def _build_render_kwargs(self) -> Dict[str, Any]: """build the edit-ready kwargs for the current page (buttons + attachments)""" @@ -370,8 +377,14 @@ class ButtonPaginator(Generic[PageT_co], discord.ui.View): self.update_buttons() if self.max_pages < 2: - self.stop() - kwargs.pop("view", None) + if self.current_page_buttons: + # single page WITH custom buttons: keep the view live so the + # buttons' callbacks still fire; strip only the navigation row + self.update_buttons(nav=False) + else: + # single page, no custom buttons: no interactive row at all + self.stop() + kwargs.pop("view", None) self.reset_files(kwargs)