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.
This commit is contained in:
@@ -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
|
||||
@@ -23,7 +24,6 @@ import asyncio
|
||||
class AntiEmojiSpam(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.emoji_threshold = 5
|
||||
|
||||
async def is_automod_enabled(self, guild_id):
|
||||
async with aiosqlite.connect(db_path("automod.db")) as db:
|
||||
@@ -118,17 +118,20 @@ class AntiEmojiSpam(commands.Cog):
|
||||
|
||||
|
||||
emoji_count = len(emoji_pattern.findall(message.content))
|
||||
th = await get_thresholds(guild_id, "anti_emoji_spam")
|
||||
emoji_threshold = int(th.get("max_emojis", 5))
|
||||
mute_minutes = float(th.get("mute_minutes", 1))
|
||||
|
||||
if emoji_count > self.emoji_threshold:
|
||||
if emoji_count > emoji_threshold:
|
||||
punishment = await self.get_punishment(guild_id)
|
||||
action_taken = None
|
||||
reason = f"Emoji Spam ({emoji_count} emojis)"
|
||||
|
||||
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=reason)
|
||||
action_taken = "Muted for 1 minute"
|
||||
action_taken = f"Muted for {int(mute_minutes)} minutes"
|
||||
elif punishment == "Kick":
|
||||
await user.kick(reason=reason)
|
||||
action_taken = "Kicked"
|
||||
|
||||
Reference in New Issue
Block a user