fix: multi-entry pages join dict content instead of dropping all but the last
The dict-entry catch-all assigned kwargs["content"] = value directly, so a per_page > 1 page combining multiple dict entries silently kept only the last entry's content while embeds/files/buttons from every entry still accumulated - an asymmetry that dropped text with no error. The dict branch's content key now routes through the same None-check/newline-join accumulation the plain-str branch already used, so every entry's content survives in order. Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
@@ -9,18 +9,18 @@ buttons) behind previous / jump / next navigation, with an optional cache button
|
|||||||
`requirements.txt`:
|
`requirements.txt`:
|
||||||
|
|
||||||
```
|
```
|
||||||
dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.8
|
dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.9
|
||||||
```
|
```
|
||||||
|
|
||||||
Direct:
|
Direct:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.8"
|
pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.9"
|
||||||
```
|
```
|
||||||
|
|
||||||
Requires `discord.py` (pulled transitively).
|
Requires `discord.py` (pulled transitively).
|
||||||
|
|
||||||
Drop the `@v0.1.8` suffix from the line above to install the latest unpinned.
|
Drop the `@v0.1.9` suffix from the line above to install the latest unpinned.
|
||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
||||||
@@ -61,6 +61,11 @@ those, or a `dict`. A dict page can carry `content`, `embed`/`embeds`,
|
|||||||
`files` accept a `discord.Attachment` and convert it via `to_file()` automatically —
|
`files` accept a `discord.Attachment` and convert it via `to_file()` automatically —
|
||||||
you never need to convert an attachment before passing it in.
|
you never need to convert an attachment before passing it in.
|
||||||
|
|
||||||
|
With `per_page > 1`, multiple entries render onto one page. `content` from each
|
||||||
|
entry (whether a plain `str` entry or a dict's `content` key) joins with `\n` in
|
||||||
|
order, same as `embeds`/`files`/`buttons` accumulate — no entry's content is
|
||||||
|
dropped in favor of another's.
|
||||||
|
|
||||||
File pages are safe to navigate back to. discord.py closes a `discord.File`'s
|
File pages are safe to navigate back to. discord.py closes a `discord.File`'s
|
||||||
underlying handle after every send/edit, so the paginator never resends your File
|
underlying handle after every send/edit, so the paginator never resends your File
|
||||||
object directly — it rebuilds a fresh `discord.File` from the same source (path or
|
object directly — it rebuilds a fresh `discord.File` from the same source (path or
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "dpy_paginator"
|
name = "dpy_paginator"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
description = "Button-navigated paginator for discord.py — config-free, injectable emojis, installable."
|
description = "Button-navigated paginator for discord.py — config-free, injectable emojis, installable."
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -279,6 +279,9 @@ class DPYPaginator(Generic[PageT_co], discord.ui.View):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"page key {key!r} has unexpected type {type(value).__name__}"
|
f"page key {key!r} has unexpected type {type(value).__name__}"
|
||||||
)
|
)
|
||||||
|
elif key == "content":
|
||||||
|
existing = kwargs["content"]
|
||||||
|
kwargs["content"] = value if existing is None else f"{existing}\n{value}"
|
||||||
else:
|
else:
|
||||||
kwargs[key] = value
|
kwargs[key] = value
|
||||||
elif isinstance(formatted_page, str):
|
elif isinstance(formatted_page, str):
|
||||||
|
|||||||
Reference in New Issue
Block a user