Skip to content

Commit

Permalink
Handle autoban filtering in DMs (#1914)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mbaruh authored Oct 26, 2021
1 parent ca634c9 commit e795914
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bot/exts/filters/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ async def _filter_message(self, msg: Message, delta: Optional[int] = None) -> No
# 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")

Expand Down

0 comments on commit e795914

Please sign in to comment.