Learn

Developer Quick Start

This page is for people who already write code who want to quickly jump in to Actions and Scripts.

Essentially:

  • Actions are event handlers that run scripts when triggered based on some criteria
  • Scripts are overpowered templates that run when an action is triggered (or sometimes for other reasons). The context determines what is available to the script.
  • Tags are functions within those scripts

As an example, this script:

Some text here
{=name;{user.name}}
{responder.text;Hello {$name}!}
Some more text here

Is similar to this code:

const name = context.user.name;
responder.text(`Hello ${name}!`);
return `Some text here\nSome more text here`;

For actions and some other script uses, any non-empty text the script outputs is added to the {responder} and then if the responder is configured (has text, an embed, attachments, etc) its sent automatically after evaluation.

{responder.channel;some-channel-id}
{responder.text;Hello world!}
{responder.send}

The script above would output an empty string, so in practice it would send a message to the channel with ID some-channel-id, finish, and then the output would be ignored.

The Tags documentation covers each tag's inputs and outputs.

Scripts themselves have many more features - variables, loops, arrays, conditions, functions, etc. You can see the Scripts section for more details. And yes, I am aware the syntax sucks, but it is what it is.

# Concepts

  • Plugins are packaged features with settings and built-in commands.
  • Actions are event handlers. Their trigger is the event source.
  • Scripts are the action body or templates used by plugins.
  • Tags are functions or value lookups, such as {user.name}.
  • Variables are script-scoped values, written with $ when read.
  • Restrictions are allow/deny rules that are checked before a feature runs.

Create a first action. The trigger pages describe the context each event supplies. For reusable helpers, see Reusable Scripts with Actions.