From 43f82d2774a7e5065cd24e47bfd1d086728fa9c0 Mon Sep 17 00:00:00 2001 From: disqualifier Date: Tue, 30 Jun 2026 21:04:51 -0400 Subject: [PATCH] fix: channel object without a guild derives the guild instead of silently dropping (dpylogger-1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DPYLogger(guild=None, channel=) passed initialize() (both int-guards skipped) but then every send failed at _get_guild(None) and got swallowed — logs never reached discord, no loud setup signal. now derive self.guild from the channel it already carries, or raise loud at setup for a truly guild-less channel (mirroring the int-channel guard). verified vs discord.py 2.7.1. bump v0.1.2 -> v0.1.3 Signed-off-by: disqualifier --- README.md | 6 +++--- pyproject.toml | 2 +- src/dpy_logger/dpy_logger.py | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5151828..1efbd25 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,18 @@ live from `bot.settings` so it can change at runtime via a command. `requirements.txt`: ``` -dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.2 +dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.3 ``` Direct: ```bash -pip install "dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.2" +pip install "dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.3" ``` Requires `discord.py` (pulled transitively). -Drop the `@v0.1.2` suffix from the line above to install the latest unpinned. +Drop the `@v0.1.3` suffix from the line above to install the latest unpinned. ## Usage diff --git a/pyproject.toml b/pyproject.toml index d05f3f2..afdc534 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "dpy_logger" -version = "0.1.2" +version = "0.1.3" description = "Leveled Discord channel logger for discord.py — config-free, injectable, installable." requires-python = ">=3.10" dependencies = [ diff --git a/src/dpy_logger/dpy_logger.py b/src/dpy_logger/dpy_logger.py index 4e95cd6..b121142 100644 --- a/src/dpy_logger/dpy_logger.py +++ b/src/dpy_logger/dpy_logger.py @@ -111,6 +111,14 @@ class DPYLogger: if not self.guild: raise ValueError(f"[dpy_logger] cannot resolve channel {self.channel} without a guild") self.channel = await self._get_channel(self.guild) + # a channel object passed with no guild (e.g. bot.get_channel(id)) would pass + # setup silently but then fail every send at _get_guild(None) — swallowed, so + # nothing reaches discord. derive the guild from the channel it already carries, + # or fail loud at setup (matching the int-channel guard above) rather than later. + if self.guild is None and isinstance(self.channel, discord.TextChannel): + self.guild = self.channel.guild + if self.guild is None and self.channel is not None: + raise ValueError("[dpy_logger] channel provided without a resolvable guild") async def _get_guild(self, guild): """resolve a guild from id-or-object, raising if unresolvable"""