From 8c3bacb2f2417c57e8eefa695245488fc52b6454 Mon Sep 17 00:00:00 2001 From: disqualifier Date: Mon, 29 Jun 2026 17:58:09 -0400 Subject: [PATCH] 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 --- README.md | 4 ++-- pyproject.toml | 2 +- src/dpy_paginator/dpy_paginator.py | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5fbcfac..936c8f7 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.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). diff --git a/pyproject.toml b/pyproject.toml index 5d83596..e994982 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ diff --git a/src/dpy_paginator/dpy_paginator.py b/src/dpy_paginator/dpy_paginator.py index ef12075..1c70a08 100644 --- a/src/dpy_paginator/dpy_paginator.py +++ b/src/dpy_paginator/dpy_paginator.py @@ -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):