aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-10-14 21:48:59 +0100
committerGravatar GitHub <[email protected]>2021-10-14 21:48:59 +0100
commit1087747ec53200e9aedbe1a36878c55980d0d090 (patch)
tree016c26b83d7f4e4ff481e0ba6970c6ebdeb63c41
parentSend the user's mention in the `watch` command. (#1867) (diff)
parentMerge branch 'main' into fix-infract-then-dm (diff)
Merge pull request #1860 from python-discord/fix-infract-then-dm
Attempt infraction before DMing
-rw-r--r--bot/exts/moderation/infraction/_scheduler.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py
index 8e844822d..1bdfbb943 100644
--- a/bot/exts/moderation/infraction/_scheduler.py
+++ b/bot/exts/moderation/infraction/_scheduler.py
@@ -161,11 +161,11 @@ class InfractionScheduler:
# send DMs to user that it doesn't share a guild with. If we were to
# apply kick/ban infractions first, this would mean that we'd make it
# impossible for us to deliver a DM. See python-discord/bot#982.
- if not infraction["hidden"]:
+ if not infraction["hidden"] and infr_type in {"ban", "kick"}:
dm_result = f"{constants.Emojis.failmail} "
dm_log_text = "\nDM: **Failed**"
- # Accordingly display whether the user was successfully notified via DM.
+ # Accordingly update whether the user was successfully notified via DM.
if await _utils.notify_infraction(user, infr_type.replace("_", " ").title(), expiry, user_reason, icon):
dm_result = ":incoming_envelope: "
dm_log_text = "\nDM: Sent"
@@ -228,6 +228,16 @@ class InfractionScheduler:
else:
infr_message = f" **{purge}{' '.join(infr_type.split('_'))}** to {user.mention}{expiry_msg}{end_msg}"
+ # If we need to DM and haven't already tried to
+ if not infraction["hidden"] and infr_type not in {"ban", "kick"}:
+ dm_result = f"{constants.Emojis.failmail} "
+ dm_log_text = "\nDM: **Failed**"
+
+ # Accordingly update whether the user was successfully notified via DM.
+ if await _utils.notify_infraction(user, infr_type.replace("_", " ").title(), expiry, user_reason, icon):
+ dm_result = ":incoming_envelope: "
+ dm_log_text = "\nDM: Sent"
+
# Send a confirmation message to the invoking context.
log.trace(f"Sending infraction #{id_} confirmation message.")
await ctx.send(f"{dm_result}{confirm_msg}{infr_message}.")