This commit is contained in:
Slipstream 2025-04-30 11:45:18 -06:00
parent 4ac7dd06a0
commit dfe0d9d221
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
2 changed files with 35 additions and 0 deletions

View File

@ -361,6 +361,27 @@ def setup_commands(cog: 'GurtCog'):
command_functions.append(gurtforceauto) # Add gurtforceauto to the list
# --- Gurt Clear Action History Command (Owner Only) ---
@cog.bot.tree.command(name="gurtclearhistory", description="Clear Gurt's internal autonomous action history. (Owner only)")
async def gurtclearhistory(interaction: discord.Interaction):
"""Handles the /gurtclearhistory command."""
if interaction.user.id != cog.bot.owner_id:
await interaction.response.send_message("⛔ Only the bot owner can clear the action history.", ephemeral=True)
return
await interaction.response.defer(ephemeral=True)
try:
result = await cog.memory_manager.clear_internal_action_logs()
if "error" in result:
await interaction.followup.send(f"⚠️ Error clearing action history: {result['error']}", ephemeral=True)
else:
await interaction.followup.send("✅ Gurt's autonomous action history has been cleared.", ephemeral=True)
except Exception as e:
import traceback
traceback.print_exc()
await interaction.followup.send(f"❌ An unexpected error occurred while clearing history: {e}", ephemeral=True)
command_functions.append(gurtclearhistory) # Add the new command
# --- Gurt Goal Command Group ---
gurtgoal_group = app_commands.Group(name="gurtgoal", description="Manage Gurt's long-term goals (Owner only)")

View File

@ -1091,3 +1091,17 @@ class MemoryManager:
except Exception as e:
logger.error(f"Error retrieving internal action logs: {e}", exc_info=True)
return []
# --- Add the new method below ---
async def clear_internal_action_logs(self) -> Dict[str, Any]:
"""Deletes all records from the internal_actions table."""
logger.info("Attempting to clear all internal action logs.")
try:
await self._db_execute("DELETE FROM internal_actions")
# Optionally, reset the autoincrement sequence if using SQLite
# await self._db_execute("DELETE FROM sqlite_sequence WHERE name='internal_actions'")
logger.info("Successfully cleared all internal action logs.")
return {"status": "cleared"}
except Exception as e:
logger.error(f"Error clearing internal action logs: {e}", exc_info=True)
return {"error": f"Database error clearing internal action logs: {str(e)}"}