diff options
author | 2022-01-08 11:37:14 +0530 | |
---|---|---|
committer | 2022-01-08 11:37:14 +0530 | |
commit | 69bcab19cbb9f4e43b9194d5ce1f3560d0094d29 (patch) | |
tree | d90eedda3624fff887fcb7ab29365774b5de65da | |
parent | migrate management.py to arrow (diff) |
disallow setting infraction durations into the past
-rw-r--r-- | bot/exts/moderation/infraction/_scheduler.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py index 57aa2d9b6..97d29eb60 100644 --- a/bot/exts/moderation/infraction/_scheduler.py +++ b/bot/exts/moderation/infraction/_scheduler.py @@ -137,8 +137,14 @@ class InfractionScheduler: icon = _utils.INFRACTION_ICONS[infr_type][0] reason = infraction["reason"] expiry = time.format_infraction_with_duration(infraction["expires_at"]) + expiry_datetime = arrow.get(infraction["expires_at"]) id_ = infraction['id'] + now_datetime = arrow.utcnow() + if expiry_datetime < now_datetime: + await ctx.send(":x: Expiration is in the past.") + return False + if user_reason is None: user_reason = reason |