Command Decorator
from main import server_details
Command Decorator
The command decorator is used to mark a coroutine as a command listener. Usage:
The fact that the coroutine's name is hi
means that the command will be <prefix>hi
.
You also get access to this ChatCommand
object which has a slew of useful information about the how the command was called.
Field | Value |
---|---|
| The name of the person that called the command, e.g. |
| The steamID of the person that called the command |
| The time that the command was called, as a |
| The name of the command that was called, e.g. |
| A list of strings that was passed as arguments to the command. E.g. - |
This decorator returns a RegisteredListener
instance
Aliases
You don't want to have to register 100's of commands for every permutation of phrasing, so why should you!
This is a simple example of how you could incorporate different function names into one command, but sometimes we need more than that!
This will allow you to check ANY string as it is passed in and perform checking on it. You just have to provide a callable, so a lambda or function reference will work! It will provide the current command as an argument and you can perform any logic you need!
Last updated