aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2023-04-06 01:44:28 +0300
committerGravatar Boris Muratov <[email protected]>2023-04-06 01:44:28 +0300
commit543bcdf8a12ed9e61f3116546d91af4e5209379d (patch)
treec875814450388bee5f7187f76647dda7d6cc7d5a
parentFix settings parser to work when no description and template first (diff)
Don't notify the user for filters triggered in DMs.
-rw-r--r--bot/exts/filtering/_settings_types/actions/infraction_and_notification.py13
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: