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 <dev@disqualifier.me>
This commit is contained in:
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user