Skip to content

Commit e795914

Browse files
authored
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.
1 parent ca634c9 commit e795914

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bot/exts/filters/filtering.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ async def _filter_message(self, msg: Message, delta: Optional[int] = None) -> No
370370
# This sends the ban confirmation directly under watchlist trigger embed, to inform
371371
# mods that the user was auto-banned for the message.
372372
context = await self.bot.get_context(msg)
373-
context.author = self.bot.get_guild(Guild.id).get_member(self.bot.user.id)
373+
context.guild = self.bot.get_guild(Guild.id)
374+
context.author = context.guild.get_member(self.bot.user.id)
374375
context.channel = self.bot.get_channel(Channels.mod_alerts)
375376
context.command = self.bot.get_command("tempban")
376377

0 commit comments

Comments
 (0)