Files
llm-bot-framework/bot/prefix_command_registry.py
2026-04-29 17:41:10 -05:00

40 lines
1.1 KiB
Python

"""
prefix_command_registry.py - Module registration for prefix commands
Same pattern as command_registry.py, but for !command-style handlers
in the command text channel. No AI, no session, no auth.
Handler signature: async def handler(message, args) -> None
message: discord.Message object
args: list of strings (everything after the command name)
"""
PREFIX_COMMANDS = {}
def register_prefix_command(name, handler):
"""
Register a handler for a prefix command.
Args:
name: String key (e.g., 'play', 'skip', 'queue')
handler: Async function(message, args) -> None
Example:
async def handle_play(message, args):
query = " ".join(args)
# ... search YouTube, join voice, play ...
register_prefix_command('play', handle_play)
"""
PREFIX_COMMANDS[name] = handler
def get_prefix_handler(name):
"""Get the registered handler for a prefix command name."""
return PREFIX_COMMANDS.get(name)
def list_prefix_commands():
"""List all registered prefix command names."""
return list(PREFIX_COMMANDS.keys())