Interactions Overview
Rich interactions let users tap buttons, pick from dropdowns, or fill modals instead of typing long command arguments. Bot Creator resolves these through the interactionCreate event.
Interaction types
((interaction.kind)) |
Trigger |
|---|---|
command |
Slash command or context menu |
button |
Button click |
select |
Select menu choice |
modal |
Modal form submission |
autocomplete |
Slash option autocomplete |
Core variables
Every interaction exposes:
| Variable | Description |
|---|---|
((interaction.customId)) |
Developer-defined ID on the component |
((interaction.userId)) |
User who triggered the interaction |
((interaction.channelId)) |
Channel ID |
((interaction.guildId)) |
Server ID (empty in DMs) |
((interaction.messageId)) |
Message holding the component |
((opts.<name>)) |
Slash command option value (or ((opts.<name>.id)) for user/channel/role IDs) |
Responding to an interaction
Unlike standard messages, an interaction expects an acknowledgment or response within 3 seconds.
In BDScript (BDFD)
Emitting text or embed content automatically sends the interaction reply. Use $ephemeral to make it visible only to the interacting user. Do not append $sendMessage in slash commands unless you need a separate message in the channel.
$if[((interaction.customId))==btn_verify]
$ephemeral
Verified! Your account has been unlocked.
$endif
In Blocks
Use the dedicated respondWithMessage action with the ephemeral checkbox:
{
"type": "respondWithMessage",
"payload": {
"content": "Verified! Your account has been unlocked.",
"ephemeral": true
}
}
In JavaScript (BDJS)
In BDJS scripts, use the global interaction object:
if (interaction.isButton()) {
await interaction.reply({ content: 'Clicked!', ephemeral: true });
}
See Components and interaction.
3. Read select values
| Select type | Getter |
|---|---|
| String select | $getStringSelectValue |
| User select | $getUserSelectUserId |
| Role select | $getRoleSelectRoleId |
| Channel select | $getChannelSelectChannelId |
Slash commands
Slash commands are interactions too. Read options directly with ((opts.<name>)) (or ((opts.<name>.id))) in BDScript and Blocks, or interaction.options.getString('name') in JavaScript.
For long operations, call $defer (or use the deferInteraction block) first to avoid Discord’s 3-second timeout.
Guides
| Guide | Topics |
|---|---|
| Handling rich interactions | Buttons, selects, modals, autocomplete |
| Building interactive buttons and select menus | Role assignment patterns |
Function reference
Browse the Components & Interactions category for all builder and getter functions.