BuildcordDocs

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:

ScopeOne value for each
GlobalBot
ServerServer
MemberMember of a server
UserDiscord 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.

ToUse
Look rows upFind rows
Repeat steps for each rowFor each row
Add a rowAdd row
Change rowsChange rows
Remove rowsDelete 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 = open

Sorting

Sorted by takes a column, then desc for largest first. Left empty, the oldest rows come first.

score desc

Avoiding 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.

On this page