Modding:Chat Commands
Jump to navigation
Jump to search
← Index
This page documents how custom chat commands are handled by the game. This is an advanced guide for mod developers.
Registering custom commands
Chat commands are modular and extensible, with a ChatCommands API to manage them.
For example, you can add a custom chat command like this:
string modId = this.ModManifest.UniqueId;
ChatCommands.Register($"{modId}_echo", this.Echo, name => $"{name} [message]: show the given message in the chat box.");
...
/// <inheritdoc cref="ChatCommandHandlerDelegate" />
private void Echo(string[] command, ChatBox chat)
{
string message = ArgUtility.GetRemainder(command, 1);
chat.addInfoMessage(message);
}
See also
- Modding:Console commands for commands that can be typed in the SMAPI console.