update
This commit is contained in:
@@ -16,6 +16,7 @@ from guardden.services.automod import (
|
||||
SpamConfig,
|
||||
normalize_domain,
|
||||
)
|
||||
from guardden.utils.notifications import send_moderation_notification
|
||||
from guardden.utils.ratelimit import RateLimitExceeded
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -187,27 +188,35 @@ class Automod(commands.Cog):
|
||||
await self._log_automod_action(message, result)
|
||||
|
||||
# Apply strike escalation if configured
|
||||
if (result.should_warn or result.should_strike) and isinstance(message.author, discord.Member):
|
||||
if (result.should_warn or result.should_strike) and isinstance(
|
||||
message.author, discord.Member
|
||||
):
|
||||
total = await self._add_strike(message.guild, message.author, result.reason)
|
||||
config = await self.bot.guild_config.get_config(message.guild.id)
|
||||
await self._apply_strike_actions(message.author, total, config)
|
||||
|
||||
# Notify the user via DM
|
||||
try:
|
||||
embed = discord.Embed(
|
||||
title=f"Message Removed in {message.guild.name}",
|
||||
description=result.reason,
|
||||
color=discord.Color.orange(),
|
||||
timestamp=datetime.now(timezone.utc),
|
||||
# Notify the user
|
||||
config = await self.bot.guild_config.get_config(message.guild.id)
|
||||
embed = discord.Embed(
|
||||
title=f"Message Removed in {message.guild.name}",
|
||||
description=result.reason,
|
||||
color=discord.Color.orange(),
|
||||
timestamp=datetime.now(timezone.utc),
|
||||
)
|
||||
if result.should_timeout:
|
||||
embed.add_field(
|
||||
name="Timeout",
|
||||
value=f"You have been timed out for {result.timeout_duration} seconds.",
|
||||
)
|
||||
|
||||
# Use notification utility to send DM with in-channel fallback
|
||||
if isinstance(message.channel, discord.TextChannel):
|
||||
await send_moderation_notification(
|
||||
user=message.author,
|
||||
channel=message.channel,
|
||||
embed=embed,
|
||||
send_in_channel=config.send_in_channel_warnings if config else False,
|
||||
)
|
||||
if result.should_timeout:
|
||||
embed.add_field(
|
||||
name="Timeout",
|
||||
value=f"You have been timed out for {result.timeout_duration} seconds.",
|
||||
)
|
||||
await message.author.send(embed=embed)
|
||||
except discord.Forbidden:
|
||||
pass # User has DMs disabled
|
||||
|
||||
async def _log_automod_action(
|
||||
self,
|
||||
@@ -472,7 +481,9 @@ class Automod(commands.Cog):
|
||||
results.append(f"**Banned Words**: {result.reason}")
|
||||
|
||||
# Check scam links
|
||||
result = self.automod.check_scam_links(text, allowlist=config.scam_allowlist if config else [])
|
||||
result = self.automod.check_scam_links(
|
||||
text, allowlist=config.scam_allowlist if config else []
|
||||
)
|
||||
if result:
|
||||
results.append(f"**Scam Detection**: {result.reason}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user