Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43f82d2774 |
@@ -10,18 +10,18 @@ live from `bot.settings` so it can change at runtime via a command.
|
|||||||
`requirements.txt`:
|
`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:
|
Direct:
|
||||||
|
|
||||||
```bash
|
```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).
|
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
|
## Usage
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "dpy_logger"
|
name = "dpy_logger"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
description = "Leveled Discord channel logger for discord.py — config-free, injectable, installable."
|
description = "Leveled Discord channel logger for discord.py — config-free, injectable, installable."
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -111,6 +111,14 @@ class DPYLogger:
|
|||||||
if not self.guild:
|
if not self.guild:
|
||||||
raise ValueError(f"[dpy_logger] cannot resolve channel {self.channel} without a guild")
|
raise ValueError(f"[dpy_logger] cannot resolve channel {self.channel} without a guild")
|
||||||
self.channel = await self._get_channel(self.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):
|
async def _get_guild(self, guild):
|
||||||
"""resolve a guild from id-or-object, raising if unresolvable"""
|
"""resolve a guild from id-or-object, raising if unresolvable"""
|
||||||
|
|||||||
Reference in New Issue
Block a user