On Command • AI Agent SDK

on_command: Decorator to register a command handler.

on_command

Method

</div>

This is a method of the BotProtocol class in the protocols module.

Decorator to register a command handler.

Signature

python
def on_command(command: str) -> Callable

Parameters

ParamField str

Command name (without /)

Returns

ResponseField Callable

The result of the operation.

Usage

python
@bot.on_command("help")
    async def handle_help(message: BotMessage):
        await bot.send_message(message.channel.channel_id, "Help text...")

Source

View on GitHub

praisonaiagents/bots/protocols.py at line 1191