From e7959146d7949377d35a433ad83f0841070587d9 Mon Sep 17 00:00:00 2001 From: Boris Muratov <8bee278@gmail.com> Date: Tue, 26 Oct 2021 13:29:37 +0300 Subject: 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. --- bot/exts/filters/filtering.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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") -- cgit v1.2.3