Execution Model and Compatibility Guide
Bot Creator offers three authoring modes. Understanding how the runtime handles Discord interactions, variables, and action boundaries prevents broken commands.
A Blocks command is a graph. How it runs (order, joins, errors,
stop) is described in section 0 below; the format is in the Graph mode guide (French).
| Mode | Format | Execution Engine | Primary Reference |
|---|---|---|---|
| Blocks (Graph) | Visual graph / JSON graph | Native Dart Engine (graph runner) | Blocks Guide & Dictionary |
| BibiScript (BibiScript) | Text & $functions |
Native AST interpreter (Dart) | Function Reference |
| BDJS (JavaScript) | JavaScript ES6+ | QuickJS / Node Sandbox | JavaScript API |
0. How a graph runs
- Order. Execution is sequential and deterministic, depth first in the order of the links: after a node, its live links are followed in order. Several links on one pin start parallel branches, but they never run at the same time. The mobile list view shows this same order.
- Joins. A node with several incoming links runs once, when all of them are resolved (arrived or dead). A path that is not taken is dead; a node whose inputs are all dead is dead too. A link that starts from a node unreachable from the entry is dead from the start.
- Branches. IF / ELSE follows the first matching pin (
then,elseif:<i>,else); Switch followscase:<value>ordefault. The other pins are dead. - Regions. Loop bodies and Try / Catch regions are closed: they run again with a fresh state at each turn, and their result keys are overwritten each time (there are no
iter<N>keys any more). - Errors. A failing node follows its
errorlinks if it has any; otherwiseerror.mode = continuenotes the error and goes on throughnext; otherwise the error goes up and the run fails. - Stop.
stop,stopUnlessandcooldownend the whole running graph. Inside a workflow called byrunWorkflow, they only end that workflow. - Acknowledgement. The interaction is deferred before the first node, unless an enabled node
deferInteractionorrespondWithModalexists in the root graph orautoDeferIfActionsisfalse. - Guards. A command has a 15 minute budget and a maximum number of steps per run.
Commands saved in the former list-of-actions format are converted to a graph when they are loaded, so they keep working.
1. Discord Interaction Lifecycle & Slash Replies
Discord interactions (Slash Commands, Buttons, Select Menus, Modals) have strict protocol constraints:
- Initial Acknowledgment (3-second deadline):
- When a BibiScript script runs for an interaction, the runner acknowledges (defers) the interaction before executing the script (
interaction.acknowledge()), unless the script source contains$newModal,$callWorkflow,$evalor$funcCall: a modal must be the immediate initial response, and those functions may open one.
- When a BibiScript script runs for an interaction, the runner acknowledges (defers) the interaction before executing the script (
- Implicit Slash Response in BibiScript:
- Text written outside functions is gathered into a pending response buffer, and embeds and components declared with functions are added to the same response.
- When the script finishes, the engine sends this buffer as the interaction response.
- You do not need
$sendMessagein a slash command to reply.$sendMessagesends a separate message to the channel, in addition to the reply buffer (probe:Hello!followed by$sendMessage[Hello2]produces one channel messageHello2and one responseHello!).
Implicit native reply:
Hello $username! Welcome to $serverName.
Embed-only native reply:
$title[Server Rules]
$description[Respect other members.]
$color[#5865F2]
Do not do this: the text is sent twice, once as the reply and once as a separate channel message.
Hello $username!
$sendMessage[Hello $username!]
- Ephemeral Visibility:
- To make an interaction reply private (visible only to the user who triggered it), add the
$ephemeralfunction (no arguments) in BibiScript:$ephemeral This message is only visible to you. - In Blocks, set
"ephemeral": trueon therespondWithMessagenode.
- To make an interaction reply private (visible only to the user who triggered it), add the
- Interaction Reply vs Channel Send:
- Replying to the interaction: Use raw text /
$ephemeralin BibiScript, orrespondWithMessagein Blocks. - Sending a message in another channel: Use
$channelSendMessage[channelID;content;(replyMessageID)]in BibiScript, orsendMessagewithchannelIdin Blocks.
- Replying to the interaction: Use raw text /
2. Variables & State Management (No $let!)
[!CAUTION] Phantom syntax: a temporary-variable setter named
$letdoes not exist in the Bot Creator engine. Unknown functions are not rejected: they are left in the output as literal text. Use$var[name;value]instead.
Bot Creator distinguishes two types of variables:
A. Temporary Execution Variables ($var)
Scoped exclusively to the current command invocation. Lost when the command finishes. Names are case-sensitive.
- Write (BibiScript):
$var[name;value] - Read (BibiScript):
$var[name] - Blocks: Action
setTemporaryVariable(name,value).
$var[userCount;$membersCount]
$var[greeting;Welcome]
$var[greeting] to all our $var[userCount] members!
B. Persistent Database Variables ($setVar / Scoped Storage)
Saved in the bot’s database across restarts.
- Global Variables:
- BibiScript:
$setVar[key;value]/$getVar[key](an extra user ID argument switches to the user scope) - Blocks:
setGlobalVariable/getGlobalVariable
- BibiScript:
- User Variables:
- BibiScript:
$setUserVar[key;value]/$getUserVar[key]. By default these are stored per server and user (theguildMemberscope); when the bot’sbdfd.userVariableSemanticssetting is1, they are stored per user across servers unless a server ID is given. - Blocks:
setScopedVariable/getScopedVariable
- BibiScript:
- Server Variables:
- BibiScript:
$setServerVar[key;value](or$setGuildVar) /$getServerVar[key]
- BibiScript:
- Member Variables (Server + User):
- BibiScript:
$setMemberVar[key;value]/$getMemberVar[key]
- BibiScript:
- Channel Variables:
- BibiScript:
$setChannelVar[key;value]/$getChannelVar[key]
- BibiScript:
3. Slash Command Options
In a BibiScript slash command, read an option with $message[optionName]: when the command is a slash command, $message[name] returns the value of the option name (an empty string if it was not given).
Reason: $message[reason]
In ((...)) placeholders (see the template system), the same options are stored as the variables opts.<option_name> (for example ((opts.reason))). For user, channel, role and mentionable options the ID is also stored as opts.<option_name>.id (for a user option, opts.<option_name> itself is the username).
[!NOTE] There is no
$slashOption[...]function: it is not registered, so it would be left as literal text.
4. Discord Ticket System
$newTicketcreates a private text channel namedticket-...for the command author (hidden from@everyone), and$isTickettests whether a channel name containsticket.$closeTicketdeletes the current channel only when its name containsticket; its page is flagged as an incomplete compatibility function.
To build a custom ticket flow with Blocks, the actions createChannel, editChannelPermissions and removeChannel exist.
Read the full walkthrough: Complete Ticket System Guide.
5. Golden Rules for Language Models (LLMs / MCP)
- Strict Separation: Never mix Blocks JSON with BibiScript syntax (use the explicit BibiScript <-> Graph conversion instead, see BibiScript and Graph). A
sendMessageblock takes a JSON payload{ "content": "..." }, not a string$sendMessage[...]. - Zero Invented Functions: Never document or suggest non-existent functions such as
$let,$sendResponse,$respondWithMessage, or$slashOption. The engine does not report them; it prints them back as text. - Respect
incompleteStatus: Alert users to the limitations of functions whose page is marked incomplete (for example$closeTicket). - Clean Acknowledgment: In slash commands, prefer the implicit reply (or
$ephemeral) without doubling up with a$sendMessage.