Cmd

From Our World of Text Wiki
Revision as of 00:20, 8 August 2023 by KKosty4ka (talk | contribs) (Created page with "cmd is a feature of OWOT that allows scripts to exchange string messages. ==Using cmd in scripts== Receiving cmd messages: <syntaxhighlight lang="javascript"> // Start receiving cmd messages w.broadcastReceive(); // cmd message event w.on("cmd", e => { /* Process the message here. Properties: kind = always "cmd" data = the actual text of the cmd message sender = the sender's channel id...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

cmd is a feature of OWOT that allows scripts to exchange string messages.

Using cmd in scripts

Receiving cmd messages:

// Start receiving cmd messages
w.broadcastReceive();

// cmd message event
w.on("cmd", e =>
{
    /*
    Process the message here.

    Properties:
    kind                = always "cmd"
    data                = the actual text of the cmd message
    sender              = the sender's channel id
    source              = always "cmd"
    username (optional) = the sender's username
    id (optional)       = the sender's Uvias ID
    */
    console.table(e);
});

Sending cmd messages:

// send a message with the text "hi" without including the username and Uvias ID
w.broadcastCommand("hi", false);

// send a message with the text "hi" with including the username and Uvias ID
w.broadcastCommand("hi", true);

Limitations

cmd has some limitations:

  • You can send only 192 cmd messages per second[1]
  • The text of a cmd message can't be longer than 2048[2]
  • cmd can only transmit strings, data of other types has to be serialized into a string[2]

References