diff options
author | 2019-10-08 19:37:59 +0200 | |
---|---|---|
committer | 2019-10-08 19:37:59 +0200 | |
commit | 5da0868a29b75be301ecfeca67901640581a21d6 (patch) | |
tree | 4f33c75a100d3b89fb5c1a12b37f4067790413c5 | |
parent | Set bot as actor of antispam infractions (diff) |
Show infraction reason when the bot is the actor
https://github.com/python-discord/bot/issues/476
We recently decided to hide the reason in the confirmation message
the bot sends after applying an infraction. In most situations, this
makes sense, since the message containing the invocation command
already contains the reason.
However, if the infraction was triggered by the bot itself (e.g., an
antispam trigger), this means that we're missing information that
provides context to the infraction.
This commit adds the reason back to the confirmation message, but
only if the actor of the infraction was the bot itself.
Closes #476
-rw-r--r-- | bot/cogs/moderation/infractions.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py index 34c439ffe..2c075f436 100644 --- a/bot/cogs/moderation/infractions.py +++ b/bot/cogs/moderation/infractions.py @@ -416,6 +416,7 @@ class Infractions(Scheduler, commands.Cog): expiry_log_text = f"Expires: {expiry}" if expiry else "" log_title = "applied" log_content = None + reason_msg = "" # DM the user about the infraction if it's not a shadow/hidden infraction. if not infraction["hidden"]: @@ -430,6 +431,9 @@ class Infractions(Scheduler, commands.Cog): dm_log_text = "\nDM: **Failed**" log_content = ctx.author.mention + if infraction["actor"] == self.bot.user.id: + reason_msg = f" (reason: {infraction['reason']})" + # Execute the necessary actions to apply the infraction on Discord. if action_coro: try: @@ -445,7 +449,7 @@ class Infractions(Scheduler, commands.Cog): log_title = "failed to apply" # Send a confirmation message to the invoking context. - await ctx.send(f"{dm_result}{confirm_msg} **{infr_type}** to {user.mention}{expiry_msg}.") + await ctx.send(f"{dm_result}{confirm_msg} **{infr_type}** to {user.mention}{expiry_msg}{reason_msg}.") # Send a log message to the mod log. await self.mod_log.send_log_message( |