From 8bba9dde052bb8cb755fe28126d90d971c09946b Mon Sep 17 00:00:00 2001 From: disqualifier Date: Mon, 6 Jul 2026 00:11:05 -0400 Subject: [PATCH] fix: check channel type before the guild-derivation guard (dpylogger-9) The wrong-type channel check sat after the no-resolvable-guild guard, so a non-TextChannel object passed without a guild raised the misleading "channel provided without a resolvable guild" instead of "is not a text channel" - the accurate message only fired when a guild was also supplied. Move the type check first so both branches report the real problem. Signed-off-by: disqualifier --- src/dpy_logger/dpy_logger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dpy_logger/dpy_logger.py b/src/dpy_logger/dpy_logger.py index a4da150..a01c18a 100644 --- a/src/dpy_logger/dpy_logger.py +++ b/src/dpy_logger/dpy_logger.py @@ -105,12 +105,12 @@ 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) + if self.channel is not None and not isinstance(self.channel, (discord.TextChannel, int)): + raise ValueError(f"[dpy_logger] channel {self.channel!r} is not a text channel") 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") - if self.channel is not None and not isinstance(self.channel, (discord.TextChannel, int)): - raise ValueError(f"[dpy_logger] channel {self.channel!r} is not a text channel") async def _get_guild(self, guild): """resolve a guild from id-or-object, raising if unresolvable"""