feat: DB for patterns

This commit is contained in:
2025-03-05 21:44:50 +01:00
parent d35bc21d89
commit a5b7872d3f
7 changed files with 137 additions and 10 deletions

View File

@@ -3,6 +3,9 @@ from typing import Literal
import discord
from discord import app_commands
from database import add_pattern
from bot.config import update_patterns
from bot.utils import compile_stats, fetch_game_stats, perform_search
GUILD_ID = 1110531063161299074
@@ -25,6 +28,22 @@ async def setup(bot):
bot.tree.on_error = on_tree_error
@bot.tree.command(
name="add_pattern",
description="Add a new message pattern to the database.",
guild=discord.Object(id=GUILD_ID),
)
@app_commands.checks.has_permissions(administrator=True)
async def add_pattern_cmd(
interaction: discord.Interaction, regex: str, response: str
):
"""Slash command to add a new message pattern to the database."""
add_pattern(regex, response)
update_patterns(regex, response)
await interaction.response.send_message(
f"Pattern added!\n**Regex:** `{regex}`\n**Response:** `{response}`"
)
@bot.tree.command(
name="search",
description="Search for servers by hostname or IP.",