Jump to content

Modding:Chat Commands

From Stardew Valley Wiki
Revision as of 19:35, 19 May 2025 by imported>BarleyZP (create page with info from Modding:Migrate to Stardew Valley 1.6.9 (main author Pathoschild))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

← Index

This page documents how custom chat commands are handled by the game. This is an advanced guide for mod developers.

Copied from Modding:Migrate to Stardew Valley 1.6.9

Chat commands are now modular and extensible in 1.6.9, with a new 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);
}