# XHandler ```py import PyserSSH.extensions.XHandler as XHandler ``` XHandler is eXternal Handler. Coding your command like discord.py ## Setup You can enable XHandler by ```py XH = XHandler() ssh = Server(XHandler=XH) ``` This enable is disable `command` event and enable 2 event. [click here](../system/events/extension.md) goto XHandler event. ## Quick Example ```py @XH.command() def calculate(client, mode="add", x=3, y=1, hello=False): """Perform mathematical operations.""" x, y, = int(x), int(y) if mode == "add": Send(client, x + y) elif mode == "sub": Send(client, x - y) elif mode == "mul": Send(client, x * y) elif mode == "div": Send(client, x / y) if hello: Send(client, "Hello World!") ``` ```bash > calculate 4 ``` this command you can custom value by use `-` in your command ```bash > calculate -mode sub 2 > calculate -x 5 -y 2 7 > calculate -x 5 -y 2 -mode mul 10 ``` you can use `--` for boolean only ```bash > calculate --hello 4 Hello World! ``` ## Help command You can disable help command by `enablehelp=False` ```bash > help No Category: calculate - Perform mathematical operations. ``` you can use `help ` for more command info ```bash > help calculate calculate Perform mathematical operations. Usage: calculate [-mode add] [-x 3] [-y 1] [--hello] ``` ## Error You can show error input command by `showusageonworng=False` ### Command Not Found ```bash > hello hello not found ``` #### Handle You can handle command not found by using `.commandnotfound` ```py def notfound(client, command): # your process XH.commandnotfound = notfound ``` ### Missing argument if enable `showusageonworng` ```bash > hello hello Usage: hello ``` or if disable `showusageonworng` ```bash Missing required argument 'testvalue' for command 'hello' ``` ### Invalid argument if enable `showusageonworng` ```bash > hello -testvalue hello Usage: hello ``` or if disable `showusageonworng` ```bash > hello -testvalue Invalid number of arguments for command 'hello'. ```