aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-01-06 17:22:20 +0100
committerGravatar Johannes Christ <[email protected]>2019-01-06 17:22:20 +0100
commit336be0df936513707941566564f6d5e22670a843 (patch)
tree20303bac89a8f8cb1c560087877b15af61f3c2c0
parentMove by-user infraction search to Django API backend. (diff)
Move by-reason infraction search to Django API backend.
-rw-r--r--bot/cogs/moderation.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index 45f35cbe4..1ea19d2df 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -944,23 +944,13 @@ class Moderation(Scheduler):
Search for infractions by their reason. Use Re2 for matching.
"""
- try:
- response = await self.bot.http_session.get(
- URLs.site_infractions,
- params={"search": reason, "hidden": "True"},
- headers=self.headers
- )
- infraction_list = await response.json()
- except ClientError:
- log.exception(f"Failed to fetch infractions matching reason `{reason}`.")
- await ctx.send(":x: An error occurred while fetching infractions.")
- return
-
+ infraction_list = await self.bot.api_client.get(
+ 'bot/infractions', params={'search': reason}
+ )
embed = Embed(
title=f"Infractions matching `{reason}` ({len(infraction_list)} total)",
colour=Colour.orange()
)
-
await self.send_infraction_list(ctx, embed, infraction_list)
# endregion