Passa al contenuto principale

Data storage

Store and read persistent values, counters, lists and lookup tables.

Build a shape value​

Builds a shape value with named, typed fields, following one of the shapes declared by this module or server. Fill each field with a value or a connection.

Inputs

NameTypeRequiredDetails
ShapeShapeYesWhich shape the new shape value follows. It decides which fields it has and what type each of them is.
ContentsShape valueYesOne value per field of the selected shape. Optional fields may be left empty and then read back as empty.

Outputs

NameTypeDetails
Shape valueShape valueThe new shape value.

Get a field of a shape value​

Reads one field of a shape value. The value has the type declared for that field, so it needs no conversion.

Inputs

NameTypeRequiredDetails
Shape valueShape valueYesThe shape value to read from.
FieldField of a shape valueYesWhich field to read. Maximum length: 64 characters.

Outputs

NameTypeDetails
ValueField valueThe field's value, or empty when the shape value does not carry that field. May be empty.

Update fields of a shape value​

Makes a copy of a shape value with only the fields you choose changed. Every other field keeps its value, so you never connect them again. Without a chosen shape the new values are not checked when the flow runs. To count up or down, use "Increase a stored number" instead: this step cannot add to a value. Reading, updating and saving an entry are separate steps, so two runs that update the same entry at the same time can overwrite each other.

Inputs

NameTypeRequiredDetails
Shape valueShape valueYesThe value to change. It is not changed itself: the step gives back an updated copy.
ShapeShapeNoThe shape of the value. When set, the new values are checked against it when the flow runs, and fields the value is missing because they were added to the shape later get their defaults.
ChangesField changesYesThe fields to change and their new values. Leave a field out to keep it. An empty value is only allowed for fields that may be empty.

Outputs

NameTypeDetails
Updated valueShape valueThe copy with your changes. Save it to keep them.

Read a stored value​

Reads a value from a storage field.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
DefaultStored valueNoValue returned when nothing is stored (must match the field type).

Outputs

NameTypeDetails
ValueStored valueStored value, or empty when nothing is stored. May be empty.

Store a value​

Writes a value to a storage field.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
ValueStored valueYesValue to store. Must match the type declared on the field.

Outputs

NameTypeDetails
ReplacedYes/NoWhether a value was already stored here and has now been overwritten.

Increase a stored number​

Adds a number to a numeric storage field, or to a number field inside a stored shape, in one safe step (atomic within one bot process) and returns the new value. A stored shape value saved before a field was added gets that field's default.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Field in the shapeField of a shape valueNoFor a stored shape value: the whole number or decimal number field to change. Leave it empty for a plain number field. Maximum length: 64 characters.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
ByDecimal numberYesAmount to add (can be negative). Turn on Subtract to take it away. Default: 1.
SubtractYes/NoYesTakes the amount away instead of adding it. Default: No.

Outputs

NameTypeDetails
New valueStored valueValue after the change.

Delete a stored value​

Deletes a stored value from a storage field.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.

List storage entries​

Returns the top entries of a storage field sorted by value (e.g. for leaderboards). People with no number in that field are left out.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Rank by fieldField of a shape valueNoFor a stored shape value: the number field to order the entries by. Leave it empty to list every entry. Maximum length: 64 characters.
DirectionSort directionYesSort direction (descending returns the highest values first). Default: Descending.
LimitWhole numberYesMaximum number of entries to return (1-100). Value: 1 to 100. Default: 10.

Outputs

NameTypeDetails
EntriesList of Storage entrySorted entries, each with its subject and value.

List storage entries (paginated)​

Returns one page of storage entries sorted by value, with total/page metadata. User-scoped entries expose their Discord user directly. People with no number in that field are left out.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Rank by fieldField of a shape valueNoFor a stored shape value: the number field to order the entries by. Leave it empty to list every entry. Maximum length: 64 characters.
DirectionSort directionYesSort direction (descending returns the highest values first). Default: Descending.
Entries per pageWhole numberYesMaximum entries per page (1-100). Value: 1 to 100. Default: 10.
PageWhole numberYesOne-based page number to return. Value: 1 to 1000000. Default: 1.

Outputs

NameTypeDetails
EntriesList of Storage entryEntries on this page. The value is already the selected field's stored value; user fields expose a resolved user.
Total entriesWhole numberTotal entries across all pages.
PageWhole numberThe requested page number.
Page countWhole numberTotal available pages.
Has next pageYes/NoWhether another page follows.
Has previous pageYes/NoWhether a previous page exists.

Get rank of a stored value​

Returns the position of a subject inside a storage field when sorted by value (e.g. "#42 on the leaderboard"). People with no number in that field are left out.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Rank by fieldField of a shape valueNoFor a stored shape value: the whole number or decimal number field to rank by. Maximum length: 64 characters.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.

Outputs

NameTypeDetails
RankWhole numberPosition sorted by value (starting at 1), or empty when nothing is stored. May be empty.

Add item to stored list​

Safely adds an item to the end of a stored list.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
ItemAnyYesItem to append.

Outputs

NameTypeDetails
New lengthWhole numberNumber of items in the list after this add. It is 1 when this add created the list, which is the safe way to check "am I the first one?" without a separate read.

Remove from stored list​

Safely removes the item at the given position from a stored list.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
IndexWhole numberYesPosition of the item to remove (starting at 0).

Outputs

NameTypeDetails
RemovedYes/NoWhether an item was actually removed. False when there was no item at that position.
New lengthWhole numberNumber of items in the list afterwards.

Set key in stored lookup table​

Safely sets a key in a stored lookup table to a value.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
KeyTextYesKey inside the stored lookup table.
ValueAnyYesValue to store under the key.

Outputs

NameTypeDetails
ReplacedYes/NoWhether that key already existed and has now been overwritten.
New key countWhole numberNumber of keys in the lookup table afterwards.

Remove key from stored lookup table​

Safely removes a key from a stored lookup table.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
KeyTextYesKey to remove from the stored lookup table.

Outputs

NameTypeDetails
RemovedYes/NoWhether the key was actually there and has now been removed.
New key countWhole numberNumber of keys in the lookup table afterwards.

Is a value stored?​

Checks whether a storage field currently has a value.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.

Outputs

NameTypeDetails
ExistsYes/NoTrue when a value is stored, otherwise false.

Remove item from stored list​

Removes matching item(s) by value from a stored list.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
ItemAnyYesValue to remove from the list.
Remove allYes/NoYesRemove every matching item instead of only the first. Default: No.

Outputs

NameTypeDetails
RemovedYes/NoWhether at least one matching item was removed.
Removed countWhole numberHow many items were removed. At most 1 unless "Remove all" is on.
New lengthWhole numberNumber of items in the list afterwards.

Stored list contains item?​

Checks whether a stored list contains a value.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
ItemAnyYesValue to look for in the list.

Outputs

NameTypeDetails
ContainsYes/NoYes when the list contains the item.

Get key from stored lookup table​

Reads a single key from a stored lookup table.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
KeyTextYesKey inside the stored lookup table.
DefaultAnyNoValue returned when the key is not present.

Outputs

NameTypeDetails
ValueAnyValue stored under the key, or the default (or empty) when absent. May be empty.

Stored lookup table has key?​

Checks whether a stored lookup table contains a key.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
KeyTextYesKey inside the stored lookup table.

Outputs

NameTypeDetails
ExistsYes/NoYes when the lookup table has the key.

List stored lookup table entries​

Returns every key and value of a stored lookup table.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.

Outputs

NameTypeDetails
EntriesList of Lookup table entryEach lookup table entry, with its key and value.

List storage keys​

Returns the keys (subject ids) that currently have a stored value for the field. Works on fields with up to 10,000 keys; a bigger field fails with a limit error you can catch.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.

Outputs

NameTypeDetails
KeysList of TextThe stored keys / subject ids.

Search storage keys​

Filters the field's keys (subject ids) by a query, ranked prefix-first then contains - like autocomplete. A blank query returns keys up to the limit. Works on fields with up to 10,000 keys; a bigger field fails with a limit error you can catch.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
QueryTextNoText to match keys against (prefix-first, then contains). Leave blank to return all keys. Maximum length: 100 characters.
LimitWhole numberYesMaximum number of keys to return (1-100). Value: 1 to 100. Default: 25.

Outputs

NameTypeDetails
KeysList of TextThe matching keys / subject ids, best matches first.

Search storage entries​

Returns the field's entries within a numeric value range, each with its overall rank in the sorted field.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Minimum valueDecimal numberNoOnly include entries whose value is at least this (leave blank for no lower bound).
Maximum valueDecimal numberNoOnly include entries whose value is at most this (leave blank for no upper bound).
DirectionSort directionYesSort direction used for ranking (descending ranks the highest value #1). Default: Descending.
LimitWhole numberYesMaximum number of matching entries to return (1-100). Value: 1 to 100. Default: 10.

Outputs

NameTypeDetails
EntriesList of Storage entryMatching entries, each with its subject, value and overall rank.

Aggregate storage field​

Computes a single number over a field's entries - sum, average, count, minimum, maximum or median - with an optional value range filter.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
OperationAggregate operationYesWhich aggregate to compute over the field's values. Default: Sum.
Minimum valueDecimal numberNoOnly include entries whose value is at least this (leave blank for no lower bound).
Maximum valueDecimal numberNoOnly include entries whose value is at most this (leave blank for no upper bound).

Outputs

NameTypeDetails
ResultDecimal numberThe computed number. Empty when there is nothing to aggregate (count returns 0). For a large whole number field it is an exact whole number of any size, and the average and median are rounded to the nearest whole number. May be empty.
CountWhole numberHow many entries contributed to the result.

Random pick from storage​

Draws random entries from a field - uniformly, or weighted by each entry's value (a raffle by ticket count). Picks are without replacement.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
CountWhole numberYesHow many entries to draw (1-100). Clamped to the number of eligible entries. Value: 1 to 100. Default: 1.
Weight byPick weightingYesHow likely each entry is to be drawn: uniform over keys, or weighted by its value. Default: Uniform.

Outputs

NameTypeDetails
PicksList of Storage entryThe drawn entries, each with its subject, value and overall rank.

Increment if (atomic)​

Increases a stored number only when its current value meets a condition. The safe way to "spend if the balance is enough".

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (for user-scoped fields).
KeyTextNoKey the value is stored under (for keyed fields). Maximum length: 100 characters.
ConditionComparisonYesHow the current value is compared to the threshold before applying. Default: At least (≥)
ThresholdDecimal numberYesValue the current value is compared against. Default: 0.
AmountDecimal numberYesHow much to add when the condition holds (use a negative amount to subtract). Default: 1.

Outputs

NameTypeDetails
AppliedYes/NoWhether the condition held and the value was changed.
New valueDecimal numberThe resulting stored value (unchanged when the condition did not hold).

Set stored value if (atomic)​

Writes a value to a storage field only when the value stored there right now meets a condition. Checking and writing happen in one single step, so two runs at the same time can never both succeed. Set "only if nothing is stored" to build a lock: whoever gets "Applied" = true may proceed, everyone else has to wait. Set "only if it equals" to change a value safely after reading it.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.
ConditionConditionYesWhat must be true of the currently stored value for the new value to be written. Default: Only if nothing is stored.
Expected valueStored valueNoValue the stored value is compared against. Only used by the "equals" and "does not equal" conditions.
ValueStored valueYesValue to store when the condition holds. Must match the type declared on the field.

Outputs

NameTypeDetails
AppliedYes/NoWhether the condition held and the value was written. With "only if nothing is stored" this is your lock: true means this run got it.
New valueStored valueThe value stored afterwards: the new value when it was written, otherwise the value that is already there (so you can see who holds the lock, or retry with the current value). May be empty.

Clear storage field​

Deletes every stored value for a field - or just one subject's/key's when a subject or key is given.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
SubjectUserNoUser the value belongs to (required for user-scoped fields).
KeyTextNoKey the value is stored under (required for keyed fields). Maximum length: 100 characters.

Format leaderboard​

Builds a ready-to-send leaderboard text from a field's top entries. Row-template tokens: %rank%, %mention% (renders <@key>, only meaningful for user-keyed fields), %key%, %value%. People with no number in that field are left out.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Rank by fieldField of a shape valueNoFor a stored shape value: the whole number or decimal number field to rank by. Each row shows that number. Maximum length: 64 characters.
DirectionSort directionYesSort direction (descending lists the highest values first). Default: Descending.
LimitWhole numberYesMaximum number of rows to render (1-100). Value: 1 to 100. Default: 10.
Row templateTextYesTemplate for each row. Tokens: %rank%, %mention%, %key%, %value%. Maximum length: 500 characters. Default: **#%rank%** %mention% - %value%.
Empty textTextNoText used when the field has no entries. Maximum length: 2000 characters.
Format numbersYes/NoYesAdd thousands separators to a numeric %value%. Default: No.

Outputs

NameTypeDetails
TextTextThe rendered leaderboard text.

Format leaderboard pages​

Builds Discord-safe leaderboard pages for Send paginated message. Tokens: %rank%, %mention%, %key%, %value%. People with no number in that field are left out.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field to operate on.
Rank by fieldField of a shape valueNoFor a stored shape value: the whole number or decimal number field to rank by. Each row shows that number. Maximum length: 64 characters.
DirectionSort directionYesSort direction (descending lists the highest values first). Default: Descending.
LimitWhole numberYesMaximum rows to render (1-100). Value: 1 to 100. Default: 10.
Row templateTextYesTemplate for each row. Tokens: %rank%, %mention%, %key%, %value%. Maximum length: 500 characters. Default: **#%rank%** %mention% - %value%.
Empty textTextNoText used when the field has no entries. Maximum length: 2000 characters.
Format numbersYes/NoYesAdd thousands separators to numeric values. Default: No.
Rows per pageWhole numberYesMaximum rows per Discord page (1-100); Discord's message limit may split earlier. Value: 1 to 100. Default: 10.

Outputs

NameTypeDetails
PagesList of Message contentPages that connect directly to Send paginated message.
Page countWhole numberNumber of generated pages.

Check and set cooldown​

Checks whether a subject is on cooldown and, if not, starts a new cooldown, all in one safe step. The safe way to rate-limit a command per user or key.

Inputs

NameTypeRequiredDetails
Storage fieldStorage fieldYesStorage field that holds the cooldown timestamps.
SubjectUserNoUser the cooldown belongs to (for user-scoped fields).
KeyTextNoKey the cooldown is stored under (for keyed fields). Maximum length: 100 characters.
DurationDurationYesHow long the cooldown lasts once started. Value: 1000 to 2592000000.

Outputs

NameTypeDetails
On cooldownYes/NoTrue when the subject was still on cooldown (nothing was changed).
Retry afterDurationTime remaining until the cooldown ends (zero when a new cooldown was just started).
Need more help?
Can't find what you're looking for? Our team is happy to help.