diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/filtering/_settings_types/actions/infraction_and_notification.py | 13 | 
1 files changed, 9 insertions, 4 deletions
diff --git a/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py b/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py index a7fb37ca9..818ba3f23 100644 --- a/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py +++ b/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py @@ -141,8 +141,8 @@ class InfractionAndNotification(ActionEntry):              "If 0, the infraction will be sent in the context channel. If the ID otherwise fails to resolve, "              "it will default to the mod-alerts channel."          ), -        "dm_content": "The contents of a message to be DMed to the offending user.", -        "dm_embed": "The contents of the embed to be DMed to the offending user." +        "dm_content": "The contents of a message to be DMed to the offending user. Doesn't send when invoked in DMs.", +        "dm_embed": "The contents of the embed to be DMed to the offending user. Doesn't send when invoked in DMs."      }      dm_content: str @@ -160,8 +160,8 @@ class InfractionAndNotification(ActionEntry):              return infr_type          return Infraction[infr_type.replace(" ", "_").upper()] -    async def action(self, ctx: FilterContext) -> None: -        """Send the notification to the user, and apply any specified infractions.""" +    async def send_message(self, ctx: FilterContext) -> None: +        """Send the notification to the user."""          # If there is no infraction to apply, any DM contents already provided in the context take precedence.          if self.infraction_type == Infraction.NONE and (ctx.dm_content or ctx.dm_embed):              dm_content = ctx.dm_content @@ -184,6 +184,11 @@ class InfractionAndNotification(ActionEntry):              except Forbidden:                  ctx.action_descriptions.append("failed to notify") +    async def action(self, ctx: FilterContext) -> None: +        """Send the notification to the user, and apply any specified infractions.""" +        if hasattr(ctx.channel, "category"):  # Don't DM the user for filters invoked in DMs. +            await self.send_message(ctx) +          if self.infraction_type != Infraction.NONE:              alerts_channel = bot_module.instance.get_channel(Channels.mod_alerts)              if self.infraction_channel:  |