diff options
| author | 2020-05-23 22:19:42 +0200 | |
|---|---|---|
| committer | 2020-05-23 22:19:42 +0200 | |
| commit | 96a3ac701dfd8dc3d59ebc0be23c695ef508f3e2 (patch) | |
| tree | e5b5983d5121a145f68262d3ec1ebe07a288f1be | |
| parent | Show a warning when redis pool isn't closed (diff) | |
| parent | Merge pull request #934 from python-discord/bug/filters/933/dont-delete-in-dms (diff) | |
Merge branch 'master' into redis_persistence
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/filtering.py | 10 | 
1 files changed, 6 insertions, 4 deletions
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py index 6a703f5a1..1e21a4ce3 100644 --- a/bot/cogs/filtering.py +++ b/bot/cogs/filtering.py @@ -4,7 +4,7 @@ from typing import Optional, Union  import discord.errors  from dateutil.relativedelta import relativedelta -from discord import Colour, DMChannel, Member, Message, TextChannel +from discord import Colour, Member, Message, TextChannel  from discord.ext.commands import Cog  from discord.utils import escape_markdown @@ -161,8 +161,10 @@ class Filtering(Cog):                          match = await _filter["function"](msg)                      if match: -                        # If this is a filter (not a watchlist), we should delete the message. -                        if _filter["type"] == "filter": +                        is_private = msg.channel.type is discord.ChannelType.private + +                        # If this is a filter (not a watchlist) and not in a DM, delete the message. +                        if _filter["type"] == "filter" and not is_private:                              try:                                  # Embeds (can?) trigger both the `on_message` and `on_message_edit`                                  # event handlers, triggering filtering twice for the same message. @@ -181,7 +183,7 @@ class Filtering(Cog):                              if _filter["user_notification"]:                                  await self.notify_member(msg.author, _filter["notification_msg"], msg.channel) -                        if isinstance(msg.channel, DMChannel): +                        if is_private:                              channel_str = "via DM"                          else:                              channel_str = f"in {msg.channel.mention}"  |