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

@@ -12,7 +12,7 @@
# ╚══════════════════════════════════════════════════════════════════╝
from pydantic import BaseModel, HttpUrl
from typing import Dict, List, Optional
from typing import Any, Dict, List, Optional
# --- Bot Schemas ---
@@ -67,13 +67,24 @@ class PrefixConfig(BaseModel):
guild_id: int
prefix: str
class AutomodEventConfig(BaseModel):
enabled: bool = False
punishment: Optional[str] = None # Mute | Kick | Ban | block_message (NSFW)
readonly_punishment: bool = False
class AutomodConfig(BaseModel):
guild_id: int
enabled: bool
punishments: Dict[str, str]
ignored_roles: List[int]
ignored_channels: List[int]
logging_channel: Optional[int]
# Legacy flat map (API event ids or bot names) — kept for older clients
punishments: Dict[str, str] = {}
events: Dict[str, AutomodEventConfig] = {}
thresholds: Dict[str, Dict[str, float]] = {}
threshold_meta: Dict[str, List[Dict[str, Any]]] = {}
ignored_roles: List[int] = []
ignored_channels: List[int] = []
logging_channel: Optional[int] = None
limits: Dict[str, int] = {"max_ignored_roles": 10, "max_ignored_channels": 10}
class TicketCategory(BaseModel):
name: str
@@ -299,10 +310,14 @@ class TicketUpdate(BaseModel):
class AutomodUpdate(BaseModel):
enabled: Optional[bool] = None
punishments: Optional[Dict[str, str]] = None
punishments: Optional[Dict[str, str]] = None # legacy
events: Optional[Dict[str, AutomodEventConfig]] = None
thresholds: Optional[Dict[str, Dict[str, float]]] = None
ignored_roles: Optional[List[int]] = None
ignored_channels: Optional[List[int]] = None
# Use a sentinel-friendly optional: omit = no change; null = clear logging
logging_channel: Optional[int] = None
clear_logging: Optional[bool] = None
class LevelingUpdate(BaseModel):
enabled: Optional[bool] = None