Skip to main content
Mark a method as the handler for a named command.
Signature
The method’s parameters are the data the client sends, validated against their annotations and any InputField() constraints before the handler runs. Handlers can be async def or plain def, and run between steps, never during one.
Returning a ModelMessage sends it back as that command’s correlated reply. The return annotation has to be one message class or None; a union is rejected when the class is declared. See Events & Messages. A handler whose name matches a generated set_<field> command replaces it.