fix: reject wrong-typed embed/file page keys; author_id is-None check (v0.1.3)

- a dict page with a wrong-typed embed/embeds/file/files key now raises a clear
  paginator-side ValueError instead of forwarding it to discord.py as a conflicting
  kwarg (opaque TypeError) (L12)
- interaction_check uses 'author_id is None' so an author_id of 0 still restricts (nit).

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
disqualifier 2026-06-29 17:58:09 -04:00
parent 20ea4f9291
commit 8c3bacb2f2
3 changed files with 12 additions and 4 deletions

View File

@ -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.2
dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.3
```
Direct:
```bash
pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.2"
pip install "dpy_paginator @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_paginator.git@v0.1.3"
```
Requires `discord.py` (pulled transitively).

View File

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "dpy_paginator"
version = "0.1.2"
version = "0.1.3"
description = "Button-navigated paginator for discord.py — config-free, injectable emojis, installable."
requires-python = ">=3.10"
dependencies = [

View File

@ -200,7 +200,7 @@ class ButtonPaginator(Generic[PageT_co], discord.ui.View):
async def interaction_check(self, interaction: Interaction) -> bool:
"""restrict interaction to author_id when set"""
if not self.author_id or self.author_id == interaction.user.id:
if self.author_id is None or self.author_id == interaction.user.id:
return True
await interaction.response.send_message("You cannot interact with this menu.", ephemeral=True)
return False
@ -259,6 +259,14 @@ class ButtonPaginator(Generic[PageT_co], discord.ui.View):
if isinstance(value, discord.Attachment):
value = await value.to_file()
self._page_kwargs["files"].append(value)
elif key in ("embed", "embeds", "file", "files"):
# a wrong-typed embed/file would otherwise fall to the catch-all and
# be forwarded verbatim, colliding with the base embeds=[]/files=[]
# and raising an opaque TypeError from inside discord.py — reject it
# here with a clear, paginator-side message
raise ValueError(
f"page key {key!r} has unexpected type {type(value).__name__}"
)
else:
self._page_kwargs[key] = value
elif isinstance(formatted_page, str):