diff options
| author | 2020-06-14 22:36:28 -0700 | |
|---|---|---|
| committer | 2020-06-14 22:36:28 -0700 | |
| commit | 09f53ca77ae79ceccad91da5e0d44d7013757f0e (patch) | |
| tree | fe87e606b2ea93aa7b5fc431fdd16f8a9a27d255 | |
| parent | Add the C# guild to the whitelist (diff) | |
Check infraction reason isn't None before shortening it
| -rw-r--r-- | bot/cogs/moderation/infractions.py | 10 | ||||
| -rw-r--r-- | bot/cogs/moderation/scheduler.py | 3 | 
2 files changed, 8 insertions, 5 deletions
| diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py index 5bfaad796..f685f6991 100644 --- a/bot/cogs/moderation/infractions.py +++ b/bot/cogs/moderation/infractions.py @@ -226,7 +226,10 @@ class Infractions(InfractionScheduler, commands.Cog):          self.mod_log.ignore(Event.member_remove, user.id) -        action = user.kick(reason=textwrap.shorten(reason, width=512, placeholder="...")) +        if reason: +            reason = textwrap.shorten(reason, width=512, placeholder="...") + +        action = user.kick(reason=reason)          await self.apply_infraction(ctx, infraction, user, action)      @respect_role_hierarchy() @@ -259,9 +262,10 @@ class Infractions(InfractionScheduler, commands.Cog):          self.mod_log.ignore(Event.member_remove, user.id) -        truncated_reason = textwrap.shorten(reason, width=512, placeholder="...") +        if reason: +            reason = textwrap.shorten(reason, width=512, placeholder="...") -        action = ctx.guild.ban(user, reason=truncated_reason, delete_message_days=0) +        action = ctx.guild.ban(user, reason=reason, delete_message_days=0)          await self.apply_infraction(ctx, infraction, user, action)          if infraction.get('expires_at') is not None: diff --git a/bot/cogs/moderation/scheduler.py b/bot/cogs/moderation/scheduler.py index b03d89537..beb201b8c 100644 --- a/bot/cogs/moderation/scheduler.py +++ b/bot/cogs/moderation/scheduler.py @@ -127,11 +127,10 @@ class InfractionScheduler(Scheduler):                      dm_result = ":incoming_envelope: "                      dm_log_text = "\nDM: Sent" -        if infraction["actor"] == self.bot.user.id: +        if reason and infraction["actor"] == self.bot.user.id:              log.trace(                  f"Infraction #{id_} actor is bot; including the reason in the confirmation message."              ) -              end_msg = f" (reason: {textwrap.shorten(reason, width=1500, placeholder='...')})"          elif ctx.channel.id not in STAFF_CHANNELS:              log.trace( | 
