aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-09-26 21:08:31 -0700
committerGravatar MarkKoz <[email protected]>2019-10-01 18:25:31 -0700
commit0e9e5ebb48c3669d946b62391793477f3b8f5824 (patch)
treeea05ff8f698b2b738fb09816e51b907ef0872d85
parentRefactor user type annotations in moderation cog (diff)
Catch errors of fetch_user when calling in send_private_embed
-rw-r--r--bot/cogs/moderation.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index ca46ccef2..c1d355a49 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -1033,16 +1033,16 @@ class Moderation(Scheduler, Cog):
Returns a boolean indicator of DM success.
"""
- # sometimes `user` is a `discord.Object`, so let's make it a proper user.
- user = await self.bot.fetch_user(user.id)
-
try:
+ # sometimes `user` is a `discord.Object`, so let's make it a proper user.
+ user = await self.bot.fetch_user(user.id)
+
await user.send(embed=embed)
return True
- except (HTTPException, Forbidden):
+ except (HTTPException, Forbidden, NotFound):
log.debug(
f"Infraction-related information could not be sent to user {user} ({user.id}). "
- "They've probably just disabled private messages."
+ "The user either could not be retrieved or probably disabled their DMs."
)
return False