aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-09-26 23:37:01 +0200
committerGravatar kwzrd <[email protected]>2020-09-27 15:40:44 +0200
commit6c069be09c4edee18b5853d990ffe1dff86ef9ce (patch)
tree7638659b502a41594b40930173c11b9880a22261
parentVerification: move disabled DM handling into helper (diff)
Verification: apply 'safe_dm' to all DM dispatches
Now, when we send a DM and it fails: * Ignore if due to disabled DMs * Log exception otherwise
-rw-r--r--bot/exts/moderation/verification.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/bot/exts/moderation/verification.py b/bot/exts/moderation/verification.py
index e10ad3e23..206556483 100644
--- a/bot/exts/moderation/verification.py
+++ b/bot/exts/moderation/verification.py
@@ -520,8 +520,10 @@ class Verification(Cog):
return # Only listen for PyDis events
log.trace(f"Sending on join message to new member: {member.id}")
- with suppress(discord.Forbidden):
- await member.send(ON_JOIN_MESSAGE)
+ try:
+ await safe_dm(member.send(ON_JOIN_MESSAGE))
+ except discord.HTTPException:
+ log.exception("DM dispatch failed on unexpected error code")
@Cog.listener()
async def on_message(self, message: discord.Message) -> None:
@@ -688,9 +690,9 @@ class Verification(Cog):
await ctx.author.remove_roles(discord.Object(constants.Roles.unverified))
try:
- await ctx.author.send(VERIFIED_MESSAGE)
- except discord.Forbidden:
- log.info(f"Sending welcome message failed for {ctx.author}.")
+ await safe_dm(ctx.author.send(VERIFIED_MESSAGE))
+ except discord.HTTPException:
+ log.exception(f"Sending welcome message failed for {ctx.author}.")
finally:
log.trace(f"Deleting accept message by {ctx.author}.")
with suppress(discord.NotFound):