aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-04-04 14:51:13 +0300
committerGravatar ks129 <[email protected]>2020-04-04 14:51:13 +0300
commitce5fcdab852600342fe69211b038426ce2821107 (patch)
tree445fd174b677763a3dc454e8ec64752b9c3f8df0
parentMerge pull request #813 from python-discord/feat/ci/b000/cache-pipenv (diff)
(Banning): Added logging and truncating to correct length for Discord Audit Log when ban reason length is more than 512 characters.
-rw-r--r--bot/cogs/moderation/infractions.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index efa19f59e..f41484711 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -244,7 +244,14 @@ class Infractions(InfractionScheduler, commands.Cog):
self.mod_log.ignore(Event.member_remove, user.id)
- action = ctx.guild.ban(user, reason=reason, delete_message_days=0)
+ if len(reason) > 512:
+ log.info("Ban reason is longer than 512 characters. Reason will be truncated for Audit Log.")
+
+ action = ctx.guild.ban(
+ user,
+ reason=f"{reason[:509]}..." if len(reason) > 512 else reason,
+ delete_message_days=0
+ )
await self.apply_infraction(ctx, infraction, user, action)
if infraction.get('expires_at') is not None: