aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/moderation/infraction/management.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py
index 4e31947d4..7596d2ec1 100644
--- a/bot/exts/moderation/infraction/management.py
+++ b/bot/exts/moderation/infraction/management.py
@@ -338,6 +338,20 @@ class ModManagement(commands.Cog):
return lines.strip()
+ async def get_latest_infraction(self, actor: int) -> t.Optional[dict]:
+ """Obtains the latest infraction from an actor."""
+ params = {
+ "actor__id": actor,
+ "ordering": "-inserted_at"
+ }
+
+ infractions = await self.bot.api_client.get("bot/infractions", params=params)
+
+ if infractions:
+ return infractions[0]
+
+ return None
+
# endregion
# This cannot be static (must have a __func__ attribute).