From 5f48d63d035fc7010755fd5595374459e060f1c6 Mon Sep 17 00:00:00 2001 From: Shakya Majumdar Date: Wed, 5 Jan 2022 14:29:15 +0530 Subject: disallow editing infraction durations into the past --- bot/exts/moderation/infraction/management.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 9649ff852..66ce698ee 100644 --- a/bot/exts/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -150,6 +150,10 @@ class ModManagement(commands.Cog): request_data['expires_at'] = None confirm_messages.append("marked as permanent") elif duration is not None: + now_datetime = datetime.now(duration.tzinfo) if duration.tzinfo else datetime.utcnow() + if duration < now_datetime: + await ctx.send(":x: Expiration is in the past.") + return request_data['expires_at'] = duration.isoformat() expiry = time.format_infraction_with_duration(request_data['expires_at']) confirm_messages.append(f"set to expire on {expiry}") -- cgit v1.2.3