Message recipes
These examples work in Kit content, a Text Display or a Source response. Each recipe explains the input it needs; the results use Anya as the example user.
A greeting with a channel
Section titled “A greeting with a channel”Combine @user.name with @channel to greet the person running the Kit and point them to the current channel:
Hi @user.name!You are in @channel.Result:
Hi Anya!You are in <#200>.In Discord, the second line contains a mention of the invocation channel. The number 200 is the example channel ID used to show the output.
A fallback for an optional input
Section titled “A fallback for an optional input”Create an optional text argument named topic, then use ?? to choose a topic when the argument is not supplied:
Topic: $(@args.topic ?? "General")Result:
Topic: GeneralHere the argument was not supplied, so the message uses “General”. An argument containing empty text stays empty, because ?? replaces only missing values (nil).
A numbered list
Section titled “A numbered list”Use the index from $each to number a list of instructions. The index starts at zero, so add one when displaying it:
$each(["Read the rules", "Introduce yourself"] as @step, @index) $(@index + 1). @step$endResult:
1. Read the rules2. Introduce yourselfReplace the list’s text with instructions for your server. To use a list supplied by the context, replace the bracketed list with its reference.
A running total
Section titled “A running total”Set the total before the loop so that each pass adds to the same variable:
$set(@total, 0)
$each([5, 10, 15] as @value) $set(@total, @total + @value)$endTotal: @totalResult:
Total: 30The three passes add 5, 10 and 15 to the outer variable, reaching 30. Keep the calculation and Total: @total in the same field, since local variables do not carry over between fields.
A selection response
Section titled “A selection response”Add a String Select to a workshop Kit with options named News and Chat. Set their values to news and chat, and allow up to two selections. Open Source on that menu and paste this reply:
$set(@rooms, { news: "Room 1", chat: "Room 2" })$each(@values as @choice) $(@rooms[@choice] ?? "Ask at the desk")$endResult:
Room 1Room 2@values contains the values the reader picked. The map pairs each value with a room. You can rename News to Announcements and leave its value as news, so the same reply still works. To add another topic, give it an option value and a key in the map. A value without a room uses “Ask at the desk”.
Clean a list of topics
Section titled “Clean a list of topics”Split pasted text, keep one entry per topic, then sort and join it for display. $slice can take the first few results using the same zero-based indexes as a list.
$set(@topics, $unique($split($trim(" Music,Art,Music "), ",")))$join($sort(@topics), " · ")Result:
Art · Music