From c77a564d592ff831c2c757caefb0753b206d2fe5 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 6 Jun 2025 21:00:07 +0000 Subject: [PATCH] Add update_rules command --- cogs/aimod_cog.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cogs/aimod_cog.py b/cogs/aimod_cog.py index 2eeeb9b..c28ee2c 100644 --- a/cogs/aimod_cog.py +++ b/cogs/aimod_cog.py @@ -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).",