""" Example command module - Copy this pattern for your domain. This module demonstrates: 1. Registering a handler with the command registry 2. Using the AI parser with custom prompts 3. Making API calls """ from bot.command_registry import register_module import ai.parser as ai_parser async def handle_example(message, session, parsed): """ Handler for 'example' interaction type. Args: message: Discord message object session: {token, user_uuid, username} parsed: Parsed JSON from AI parser """ action = parsed.get("action", "unknown") token = session["token"] user_uuid = session["user_uuid"] if action == "check": await message.channel.send( f"Checking example items for {session['username']}..." ) elif action == "add": item_name = parsed.get("item_name", "unnamed") await message.channel.send(f"Adding example item: **{item_name}**") else: await message.channel.send(f"Unknown example action: {action}") def validate_example_json(data): """Validate parsed JSON for example commands. Return list of errors.""" errors = [] if not isinstance(data, dict): return ["Response must be a JSON object"] if "error" in data: return [] if "action" not in data: errors.append("Missing required field: action") action = data.get("action") if action == "add" and "item_name" not in data: errors.append("Missing required field for add: item_name") return errors # Register the module register_module("example", handle_example) # Register the validator ai_parser.register_validator("example", validate_example_json)