diff options
| author | 2021-10-16 09:31:05 +0300 | |
|---|---|---|
| committer | 2021-10-16 09:31:05 +0300 | |
| commit | 9325c79bb458136fd22424008041ef4c00cd63d4 (patch) | |
| tree | 385d94bb25525dacab7ff3e018109a60685b3617 | |
| parent | Merge pull request #1874 from python-discord/fix-bot-1869 (diff) | |
Do not try to calculate expiry if infraction is permanent on reapply
| -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." |