diff options
| author | 2020-04-04 16:03:58 +0300 | |
|---|---|---|
| committer | 2020-04-04 16:03:58 +0300 | |
| commit | 80e483a7ebaf57e6544429343c94cf0eed8821ef (patch) | |
| tree | a9b6f9a47cfd47909cab4567a76b87ef3ff2991a | |
| parent | (Kick Command): Added logging and truncating to correct length for Discord Au... (diff) | |
(Ban and Kick): Replaced force reason truncating with `textwrap.shorten`.
| -rw-r--r-- | bot/cogs/moderation/infractions.py | 5 | 
1 files changed, 3 insertions, 2 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py index f8c3e8da3..a0bdf0d97 100644 --- a/bot/cogs/moderation/infractions.py +++ b/bot/cogs/moderation/infractions.py @@ -1,4 +1,5 @@  import logging +import textwrap  import typing as t  import discord @@ -228,7 +229,7 @@ class Infractions(InfractionScheduler, commands.Cog):          if len(reason) > 512:              log.info("Kick reason is longer than 512 characters. Reason will be truncated for Audit Log.") -        action = user.kick(reason=f"{reason[:509]}..." if len(reason) > 512 else reason) +        action = user.kick(textwrap.shorten(reason, width=509, placeholder="...") if len(reason) > 512 else reason)          await self.apply_infraction(ctx, infraction, user, action)      @respect_role_hierarchy() @@ -252,7 +253,7 @@ class Infractions(InfractionScheduler, commands.Cog):          action = ctx.guild.ban(              user, -            reason=f"{reason[:509]}..." if len(reason) > 512 else reason, +            reason=textwrap.shorten(reason, width=509, placeholder="...") if len(reason) > 512 else reason,              delete_message_days=0          )          await self.apply_infraction(ctx, infraction, user, action)  |