diff options
-rw-r--r-- | bot/cogs/antispam.py | 4 | ||||
-rw-r--r-- | bot/cogs/moderation/infractions.py | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/bot/cogs/antispam.py b/bot/cogs/antispam.py index cd1940aaa..fd7e4edb0 100644 --- a/bot/cogs/antispam.py +++ b/bot/cogs/antispam.py @@ -207,8 +207,10 @@ class AntiSpam(Cog): if not any(role.id == self.muted_role.id for role in member.roles): remove_role_after = AntiSpamConfig.punishment['remove_after'] - # We need context, let's get it + # Get context and make sure the bot becomes the actor of infraction by patching the `author` attributes context = await self.bot.get_context(msg) + context.author = self.bot.user + context.message.author = self.bot.user # Since we're going to invoke the tempmute command directly, we need to manually call the converter. dt_remove_role_after = await self.expiration_date_converter.convert(context, f"{remove_role_after}S") 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( |