Add update_rules command

This commit is contained in:
Codex 2025-06-06 21:00:07 +00:00 committed by Slipstream
parent fcedfd3760
commit c77a564d59
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -30,6 +30,7 @@ from gurt.config import (
LOCATION,
) # Assuming gurt.config exists and has these
from . import aimod_config as aimod_config_module
from .aimod_config import (
DEFAULT_VERTEX_AI_MODEL,
STANDARD_SAFETY_SETTINGS,
@ -741,6 +742,33 @@ class AIModerationCog(commands.Cog):
ephemeral=False,
)
@config_subgroup.command(
name="update_rules",
description="Update server rules from the specified channel.",
)
@app_commands.describe(channel="The channel containing the server rules.")
@app_commands.checks.has_permissions(administrator=True)
async def update_rules(
self, interaction: discord.Interaction, channel: discord.TextChannel
) -> None:
"""Pull the server rules from a channel and update the global config."""
messages = []
async for msg in channel.history(limit=None, oldest_first=True):
if msg.content:
messages.append(msg.content)
if not messages:
await interaction.response.send_message(
"No messages found in that channel.", ephemeral=True
)
return
rules_text = "\n\n".join(messages).strip()
aimod_config_module.SERVER_RULES = rules_text
await interaction.response.send_message(
f"Server rules updated from {channel.mention}.", ephemeral=False
)
@infractions_subgroup.command(
name="view",
description="View a user's AI moderation infraction history (mod/admin only).",