aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ionite34 <[email protected]>2022-08-06 13:11:36 -0400
committerGravatar Ionite <[email protected]>2022-08-16 16:38:26 -0400
commit1212ac808380280c7b7625eb2a43c75c92e17d5f (patch)
tree11c6d0841792cea8fe30ffe4c2547a069d8723a2
parentChanged datetime.now to arrow.utcnow (diff)
Removed `inserted_at` fallback
Given API updates, the fallback is not needed
-rw-r--r--bot/exts/moderation/infraction/_scheduler.py11
-rw-r--r--bot/exts/moderation/infraction/_utils.py7
2 files changed, 5 insertions, 13 deletions
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py
index cfb585bf5..cb3f7149f 100644
--- a/bot/exts/moderation/infraction/_scheduler.py
+++ b/bot/exts/moderation/infraction/_scheduler.py
@@ -138,13 +138,10 @@ class InfractionScheduler:
icon = _utils.INFRACTION_ICONS[infr_type][0]
reason = infraction["reason"]
id_ = infraction['id']
-
- if "last_applied" in infraction:
- origin = infraction["last_applied"]
- else: # Fallback for previous API versions without `last_applied`
- log.trace(f"No last_applied for infraction {id_}, using inserted_at time.")
- origin = infraction["inserted_at"]
- expiry = time.format_with_duration(infraction["expires_at"], origin)
+ expiry = time.format_with_duration(
+ infraction["expires_at"],
+ infraction["last_applied"]
+ )
if user_reason is None:
user_reason = reason
diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py
index eda56b97c..407c97251 100644
--- a/bot/exts/moderation/infraction/_utils.py
+++ b/bot/exts/moderation/infraction/_utils.py
@@ -188,12 +188,7 @@ async def notify_infraction(
expires_at = "Never"
duration = "Permanent"
else:
- if "last_applied" in infraction:
- origin = infraction["last_applied"]
- else: # Fallback for previous API versions without `last_applied`
- log.trace(f"No last_applied for infraction {infraction}, using inserted_at time.")
- origin = infraction["inserted_at"]
- origin = arrow.get(origin)
+ origin = arrow.get(infraction["last_applied"])
expiry = arrow.get(infraction["expires_at"])
expires_at = time.format_relative(expiry)
duration = time.humanize_delta(origin, expiry, max_units=2)