Skip to content

Commit d898ce5

Browse files
committed
Add debug logging to silent exception handlers
- Import logging module and create logger for admin cog - Add debug logging when DM to kicked user fails (discord.Forbidden) - Add debug logging when DM to banned user fails (discord.Forbidden) - Improve troubleshooting capability without cluttering normal logs These logs will only appear when logging level is set to DEBUG, allowing administrators to diagnose DM delivery issues during moderation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 379f74e commit d898ce5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cogs/admin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
from discord.ext import commands
1010
from typing import TYPE_CHECKING, Optional, Literal
1111
from datetime import timedelta
12+
import logging
1213

1314
from helpers.colors import MAIN_EMBED_COLOR, ERROR_EMBED_COLOR, SUCCESS_EMBED_COLOR
1415
from helpers.ui import ConfirmationView
1516

17+
logger = logging.getLogger(__name__)
18+
1619
if TYPE_CHECKING:
1720
from core.bot import RickBot
1821

@@ -149,7 +152,9 @@ async def kick(self, interaction: discord.Interaction, member: discord.Member):
149152
)
150153
await member.send(embed=dm_embed)
151154
except discord.Forbidden:
152-
pass # Can't DM user
155+
logger.debug(
156+
f"Could not DM {member} ({member.id}) about kick - DMs disabled or blocked"
157+
)
153158

154159
# Kick the member
155160
await member.kick(reason=f"{interaction.user} | {reason}")
@@ -296,7 +301,9 @@ async def ban(
296301
)
297302
await target.send(embed=dm_embed)
298303
except discord.Forbidden:
299-
pass # Can't DM user
304+
logger.debug(
305+
f"Could not DM {target} ({target.id}) about ban - DMs disabled or blocked"
306+
)
300307

301308
# Ban the user
302309
await interaction.guild.ban(

0 commit comments

Comments
 (0)