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"""