Enhance AutoMod configuration by introducing event-specific settings and thresholds. Refactor Automod schemas to include event configurations, thresholds, and limits for ignored roles and channels. Update database interactions to support new structure and improve handling of AutoMod rules in cogs, ensuring dynamic thresholds for various events. Update dashboard components to accommodate new configurations and improve user experience in managing AutoMod settings.
Some checks failed
CI / Bot (Python) (push) Successful in 12s
CI / Dashboard (Next.js) (push) Failing after 9s

This commit is contained in:
TheOnlyMace
2026-07-21 23:05:05 +02:00
parent d24b810164
commit 36b32de34c
17 changed files with 842 additions and 165 deletions

View File

@@ -11,6 +11,7 @@
# ║ ║
# ╚══════════════════════════════════════════════════════════════════╝
from utils.db_paths import db_path
from utils.automod_settings import get_thresholds
import discord
from utils.emoji import TICK
@@ -22,8 +23,6 @@ from datetime import timedelta
class AntiCaps(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.caps_threshold = 70
self.mute_duration = 2 * 60
async def is_automod_enabled(self, guild_id):
async with aiosqlite.connect(db_path("automod.db")) as db:
@@ -74,9 +73,6 @@ class AntiCaps(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message):
if len(message.content) < 45:
return
if message.author.bot:
return
@@ -85,6 +81,14 @@ class AntiCaps(commands.Cog):
channel = message.channel
guild_id = guild.id
th = await get_thresholds(guild_id, "anti_caps")
min_length = int(th.get("min_length", 45))
caps_threshold = float(th.get("percent", 70))
mute_minutes = float(th.get("mute_minutes", 1))
if len(message.content) < min_length:
return
if not await self.is_automod_enabled(guild_id) or not await self.is_anti_caps_enabled(guild_id):
return
@@ -103,16 +107,16 @@ class AntiCaps(commands.Cog):
caps_count = sum(1 for c in message.content if c.isupper())
caps_percentage = (caps_count / len(message.content)) * 100
if caps_percentage > self.caps_threshold:
if caps_percentage > caps_threshold:
punishment = await self.get_punishment(guild_id)
action_taken = None
reason = "Excessive Caps"
try:
if punishment == "Mute":
timeout_duration = discord.utils.utcnow() + timedelta(minutes=1)
timeout_duration = discord.utils.utcnow() + timedelta(minutes=mute_minutes)
await user.edit(timed_out_until=timeout_duration, reason="Excessive Caps")
action_taken = "Muted for 1 minutes"
action_taken = f"Muted for {int(mute_minutes)} minutes"
elif punishment == "Kick":
await user.kick(reason="Excessive Caps")
action_taken = "Kicked"