aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-10-08 19:09:55 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-10-08 19:09:55 +0200
commitc6929bc3224fa2756e4faa78d3c2110046243318 (patch)
tree65b3c1188f5c7f43e3f8955ab555d5f618d4d1e9
parentMerge pull request #462 from python-discord/moderation-cleanup (diff)
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.
-rw-r--r--bot/cogs/antispam.py4
1 files changed, 3 insertions, 1 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")