Sending Commands
Sends a command payload to all subscribers listening to the specified command channel.
This broadcasts the payload to all active EventSource connections that are streaming the same command type. The operation is asynchronous and will complete once the command has been distributed to all subscribers.
Parameters
command
: The command channel name to broadcast topayload
: The data to send to all subscribers (must be JSON-serializable)
Examples
Send Notification to All MOD Windows
// Send a notification to all mod windows
await commands.send("notifications", {
type: "info",
title: "Update Available",
message: "A new version of the character is available",
timestamp: Date.now()
});
Related Functions
stream()
- Listen for commands on a specific channelwebviews.open()
- Create webviews that can receive commandspreferences.save()
- Persist data that's shared via commands