From c6929bc3224fa2756e4faa78d3c2110046243318 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> Date: Tue, 8 Oct 2019 19:09:55 +0200 Subject: Set bot as actor of antispam infractions As mentioned in #476, the bot currently sets the actor of infractions applied due to an antispam rule trigger to the offending member. The reason is that we get a `Context` object from the message that triggered the antispam rule, which was sent by the offender. I've changed it by patching both available author attributes, `Context.author` and `Context.message.author` with the bot user. --- bot/cogs/antispam.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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") -- cgit v1.2.3