diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/moderation/infraction/_scheduler.py | 14 | 
1 files changed, 9 insertions, 5 deletions
| diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py index 2a1ccb9d4..fc915016c 100644 --- a/bot/exts/moderation/infraction/_scheduler.py +++ b/bot/exts/moderation/infraction/_scheduler.py @@ -81,12 +81,16 @@ class InfractionScheduler:          apply_coro: t.Optional[t.Awaitable]      ) -> None:          """Reapply an infraction if it's still active or deactivate it if less than 60 sec left.""" -        # Calculate the time remaining, in seconds, for the mute. -        expiry = dateutil.parser.isoparse(infraction["expires_at"]).replace(tzinfo=None) -        delta = (expiry - datetime.utcnow()).total_seconds() +        if infraction["expires_at"] is not None: +            # Calculate the time remaining, in seconds, for the mute. +            expiry = dateutil.parser.isoparse(infraction["expires_at"]).replace(tzinfo=None) +            delta = (expiry - datetime.utcnow()).total_seconds() +        else: +            # If the infraction is permanent, it is not possible to get the time remaining. +            delta = None -        # Mark as inactive if less than a minute remains. -        if delta < 60: +        # Mark as inactive if the infraction is not permanent and less than a minute remains. +        if delta is not None and delta < 60:              log.info(                  "Infraction will be deactivated instead of re-applied "                  "because less than 1 minute remains." | 
