aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2021-10-26 13:29:37 +0300
committerGravatar GitHub <[email protected]>2021-10-26 11:29:37 +0100
commite7959146d7949377d35a433ad83f0841070587d9 (patch)
treedfc96806355fed845b6c200ec8ba48aeceabaadc
parentMerge pull request #1893 from python-discord/filters/autoban (diff)
Handle autoban filtering in DMs (#1914)
An autoban trigger being sent in DMs caused the ban to fail, but for it to still be registered in the database. That is becuase the ban command uses the `ctx.guild.ban` method, but in DMs `ctx.guild` is None. This commit solves it by overriding the `context.guild` field.
-rw-r--r--bot/exts/filters/filtering.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py
index b7a7e8093..022b4ab02 100644
--- a/bot/exts/filters/filtering.py
+++ b/bot/exts/filters/filtering.py
@@ -370,7 +370,8 @@ class Filtering(Cog):
# This sends the ban confirmation directly under watchlist trigger embed, to inform
# mods that the user was auto-banned for the message.
context = await self.bot.get_context(msg)
- context.author = self.bot.get_guild(Guild.id).get_member(self.bot.user.id)
+ context.guild = self.bot.get_guild(Guild.id)
+ context.author = context.guild.get_member(self.bot.user.id)
context.channel = self.bot.get_channel(Channels.mod_alerts)
context.command = self.bot.get_command("tempban")