aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar momothereal <[email protected]>2018-07-25 00:31:22 -0400
committerGravatar momothereal <[email protected]>2018-07-25 00:31:22 -0400
commite1b32b984f076306fe88bf218e070cb3deb7757d (patch)
tree53167e741cd2461e36d4d720e066b89bd5bc3484
parentAdd kick command (diff)
Add 'edit reason' command
-rw-r--r--bot/cogs/moderation.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index ae4217d78..7ffd64b37 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -375,6 +375,8 @@ class Moderation:
await ctx.send(":x: There was an error removing the infraction.")
return
+ # Edit infraction commands
+
@with_role(*MODERATION_ROLES)
@command(name="infraction.edit.duration")
async def edit_duration(self, ctx, infraction_id: str, duration: str):
@@ -418,6 +420,35 @@ class Moderation:
await ctx.send(":x: There was an error updating the infraction.")
return
+ @with_role(*MODERATION_ROLES)
+ @command(name="infraction.edit.reason")
+ async def edit_reason(self, ctx, infraction_id: str, reason: str):
+ """
+ Sets the reason of the given infraction.
+ :param infraction_id: the id (UUID) of the infraction
+ :param reason: the new reason of the infraction
+ """
+ try:
+ response = await self.bot.http_session.patch(
+ URLs.site_infractions,
+ json={
+ "id": infraction_id,
+ "reason": reason
+ },
+ headers=self.headers
+ )
+ response_object = await response.json()
+ if "error_code" in response_object or response_object.get("success") is False:
+ # something went wrong
+ await ctx.send(f":x: There was an error updating the infraction: {response_object['error_message']}")
+ return
+
+ await ctx.send(f":ok_hand: Updated infraction: set reason to \"{reason}\".")
+ except Exception:
+ log.exception("There was an error updating an infraction.")
+ await ctx.send(":x: There was an error updating the infraction.")
+ return
+
# Search infractions
@with_role(*MODERATION_ROLES)