fix: rebuild fresh File per render, convert Attachments in files= list, thread page state through locals
discord.py closes a discord.File's fp after every send/edit, so reusing the same File object across renders raised ValueError on navigating back to a file page; reset_files now rebuilds a fresh File from the same source instead. The dict page 'files' list never converted discord.Attachment to File (unlike the singular 'file' key), crashing reset_files with AttributeError; it now converts via to_file() like its sibling. get_page_kwargs also built render state in instance attributes across real await points, letting two near-simultaneous interactions interleave into a merged render; it now builds in locals and threads them through the recursive branch, publishing self.current_page_buttons only once a page is fully assembled. Bump to v0.1.5. 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`:
|
||||
|
||||
```
|
||||
dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.4
|
||||
dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.5
|
||||
```
|
||||
|
||||
Direct:
|
||||
|
||||
```bash
|
||||
pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.4"
|
||||
pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.5"
|
||||
```
|
||||
|
||||
Requires `discord.py` (pulled transitively).
|
||||
|
||||
Drop the `@v0.1.4` suffix from the line above to install the latest unpinned.
|
||||
Drop the `@v0.1.5` suffix from the line above to install the latest unpinned.
|
||||
|
||||
## Basic usage
|
||||
|
||||
@@ -54,7 +54,15 @@ Unset keys fall back to the Unicode defaults.
|
||||
|
||||
A page may be a `str`, `discord.Embed`, `discord.File`/`Attachment`, a sequence of
|
||||
those, or a `dict`. A dict page can carry `content`, `embed`/`embeds`,
|
||||
`file`/`files`, and a `buttons` list of custom button configs.
|
||||
`file`/`files`, and a `buttons` list of custom button configs. Both `file` and
|
||||
`files` accept a `discord.Attachment` and convert it via `to_file()` automatically —
|
||||
you never need to convert an attachment before passing it in.
|
||||
|
||||
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
|
||||
object directly — it rebuilds a fresh `discord.File` from the same source (path or
|
||||
buffer) on every render, so `pages` can hold a `discord.File` once and be paged
|
||||
back and forth indefinitely.
|
||||
|
||||
## Custom per-page buttons
|
||||
|
||||
|
||||
Reference in New Issue
Block a user