Compare commits
2
Commits
0e0646a5d6
...
849a6f51e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
849a6f51e7 | ||
|
|
982651af7a |
No files matched your search
@@ -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@v1.0.0
|
dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v1.1.1
|
||||||
```
|
```
|
||||||
|
|
||||||
Direct:
|
Direct:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install "dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v1.0.0"
|
pip install "dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v1.1.1"
|
||||||
```
|
```
|
||||||
|
|
||||||
Requires `discord.py` (pulled transitively).
|
Requires `discord.py` (pulled transitively).
|
||||||
|
|
||||||
Drop the `@v1.0.0` suffix from the line above to install the latest unpinned.
|
Drop the `@v1.1.1` 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 = "1.1.0"
|
version = "1.1.1"
|
||||||
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 = [
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ class DPYLogger:
|
|||||||
raise ValueError("[dpy_logger] no guild available for logging")
|
raise ValueError("[dpy_logger] no guild available for logging")
|
||||||
|
|
||||||
async def _get_channel(self, guild, override=False):
|
async def _get_channel(self, guild, override=False):
|
||||||
"""resolve the log channel, preferring self.channel when the guild matches"""
|
"""resolve the log channel, preferring self.channel when the guild matches
|
||||||
|
|
||||||
|
the guild's channel cache is tried first; fetch_channel (an HTTP GET) only runs on a
|
||||||
|
cache miss (e.g. a fetched, uncached guild)"""
|
||||||
if not guild:
|
if not guild:
|
||||||
raise ValueError("[dpy_logger] cannot resolve channel without a guild")
|
raise ValueError("[dpy_logger] cannot resolve channel without a guild")
|
||||||
|
|
||||||
@@ -141,7 +144,7 @@ class DPYLogger:
|
|||||||
# fetch_channel raises NotFound/Forbidden/HTTPException/InvalidData (a
|
# fetch_channel raises NotFound/Forbidden/HTTPException/InvalidData (a
|
||||||
# ClientException, not an HTTPException); normalize all to ValueError
|
# ClientException, not an HTTPException); normalize all to ValueError
|
||||||
try:
|
try:
|
||||||
channel = await guild.fetch_channel(self.channel)
|
channel = guild.get_channel(self.channel) or await guild.fetch_channel(self.channel)
|
||||||
except (discord.HTTPException, discord.ClientException) as error:
|
except (discord.HTTPException, discord.ClientException) as error:
|
||||||
raise ValueError(f"[dpy_logger] could not fetch channel {self.channel}: {error}") from error
|
raise ValueError(f"[dpy_logger] could not fetch channel {self.channel}: {error}") from error
|
||||||
if not isinstance(channel, discord.TextChannel):
|
if not isinstance(channel, discord.TextChannel):
|
||||||
@@ -153,7 +156,7 @@ class DPYLogger:
|
|||||||
except KeyError as error:
|
except KeyError as error:
|
||||||
raise ValueError(f"[dpy_logger] no log channel configured for guild {guild.id}") from error
|
raise ValueError(f"[dpy_logger] no log channel configured for guild {guild.id}") from error
|
||||||
try:
|
try:
|
||||||
channel = await guild.fetch_channel(channel_id)
|
channel = guild.get_channel(channel_id) or await guild.fetch_channel(channel_id)
|
||||||
except (discord.HTTPException, discord.ClientException) as error:
|
except (discord.HTTPException, discord.ClientException) as error:
|
||||||
raise ValueError(f"[dpy_logger] could not fetch channel {channel_id}: {error}") from error
|
raise ValueError(f"[dpy_logger] could not fetch channel {channel_id}: {error}") from error
|
||||||
if not isinstance(channel, discord.TextChannel):
|
if not isinstance(channel, discord.TextChannel):
|
||||||
|
|||||||
Reference in new issue
Block a user