diff options
author | 2023-12-09 16:33:25 +0100 | |
---|---|---|
committer | 2024-03-29 23:38:50 +0100 | |
commit | 0254200dca80d16d6816ce817c16ab5f4f4c85fc (patch) | |
tree | 436b3f626b062829793302c878f465a25b59c628 | |
parent | Bump sentry-sdk from 1.43.0 to 1.44.0 (#2986) (diff) |
allow timeout edits
-rw-r--r-- | bot/exts/moderation/infraction/management.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 93959042b..9fd851245 100644 --- a/bot/exts/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -197,8 +197,8 @@ class ModManagement(commands.Cog): # Update `last_applied` if expiry changes. request_data["last_applied"] = origin.isoformat() request_data["expires_at"] = expiry.isoformat() - expiry = time.format_with_duration(expiry, origin) - confirm_messages.append(f"set to expire on {expiry}") + formatted_expiry = time.format_with_duration(expiry, origin) + confirm_messages.append(f"set to expire on {formatted_expiry}") else: confirm_messages.append("expiry unchanged") @@ -218,6 +218,10 @@ class ModManagement(commands.Cog): json=request_data, ) + # Get information about the infraction's user + user_id = new_infraction["user"] + user = await get_or_fetch_member(ctx.guild, user_id) + # Re-schedule infraction if the expiration has been updated if "expires_at" in request_data: # A scheduled task should only exist if the old infraction wasn't permanent @@ -227,6 +231,9 @@ class ModManagement(commands.Cog): # If the infraction was not marked as permanent, schedule a new expiration task if request_data["expires_at"]: self.infractions_cog.schedule_expiration(new_infraction) + # Timeouts are handled by Discord itself, so we need to edit the expiry in Discord as well + if infraction["type"] == "timeout": + await user.edit(reason=reason, timed_out_until=expiry) log_text += f""" Previous expiry: {time.until_expiration(infraction['expires_at'])} @@ -236,10 +243,6 @@ class ModManagement(commands.Cog): changes = " & ".join(confirm_messages) await ctx.send(f":ok_hand: Updated infraction #{infraction_id}: {changes}") - # Get information about the infraction's user - user_id = new_infraction["user"] - user = await get_or_fetch_member(ctx.guild, user_id) - if user: user_text = messages.format_user(user) thumbnail = user.display_avatar.url |