fix: channel object without a guild derives the guild instead of silently dropping (dpylogger-1)
DPYLogger(guild=None, channel=<TextChannel>) 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 <dev@disqualifier.me>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -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 = [
|
||||
|
||||
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user