Variables and collections
Store single values in variables and tables of rows in collections.
A bot's data lives in the data store, not in the blueprint. The blueprint only declares what exists.
Variables
A variable holds one value. It has a name, a type, a scope and a default.
Types: text, number, boolean and list.
Scopes decide whose value it is:
| Scope | One value for each |
|---|---|
| Global | Bot |
| Server | Server |
| Member | Member of a server |
| User | Discord user, across servers |
Read a variable with {var.name}. Change it with Set variable, Change a number or Run equation on variable. Clear it with Delete variable.
For a value that matters only during one run, use Set a unique variable, which you read as {temp.name}.
Collections
A collection is a table. It has named columns, and each column is text, number, boolean, user or date. Each row gets a number, available as {row.id}.
Use collections for lists that grow, such as tickets, suggestions, giveaway entries or balances.
| To | Use |
|---|---|
| Look rows up | Find rows |
| Repeat steps for each row | For each row |
| Add a row | Add row |
| Change rows | Change rows |
| Remove rows | Delete rows |
Conditions
Steps that look rows up take a Where condition. Compare a column with =, !=, <, <=, > or >=, and join several with and. An empty condition matches every row.
user = {user.id} and status = openSorting
Sorted by takes a column, then desc for largest first. Left empty, the oldest rows come first.
score descAvoiding races
Two runs can read the same row at the same moment. To keep both from acting on stale data, either use Add to in Change rows, which counts both runs, or put One run at a time before the read.