Skip to main content

Lists

A list holds several values in order. Discord blocks hand you lists all the time: the members who reacted to a message, the permissions on a role, the files someone uploaded to a modal.

The Lists category

info

Lists in DisFuse start at position 1, not 0. get # 1 is the first item.

Making a list​

BlockWhat it does
create list withBuilds a list out of the values you plug in. Click the gear to add more slots.
repeat itemBuilds a list by repeating one value.
split textSplits text into a list on a separator, or joins a list back into text.
mergeJoins two lists into one.

Reading a list​

BlockReturns
lengthHow many items the list has.
is emptyTrue when the list has nothing in it.
get indexOne item, by position. The dropdowns also offer first, last and random.
index ofThe position of an item, or 0 when it is not there.
sublistA slice of the list.

Changing a list​

BlockWhat it does
set indexReplaces or inserts an item at a position.
sortSorts numerically, alphabetically, or ignoring case, ascending or descending.
reverseReverses the order.

Searching a list​

Two blocks run a test over every item for you.

The filter block

filter list ... by keeps only the items the test says yes to. Inside the test, item in loop is the item being checked.

The find block

find first in list ... that matches returns the first item the test says yes to, and nothing if there is none.

Looping over a list​

Use for each item in list from Loops. It gives you each item in turn, which is usually simpler than counting positions yourself.

Example​

To pick a random winner from everyone who reacted to a giveaway message:

  1. get users of reaction ... with emoji 🎉 from Message gives you a list.
  2. filter that list, keeping only entries where is user a bot? is false.
  3. in list ... get random picks the winner.