On this page
JavaScript API
JavaScript API Overview
Script globals available in BDJS (JavaScript) bots — db, interaction, message, and more.
Bot Creator supports two scripting modes: BDScript ($functions) and BDJS (JavaScript). When your bot uses BDJS, command handlers run as async JavaScript with a sandboxed set of globals.
Check your bot’s mode with $scriptLanguage — it returns bdjs or bdscript.
Available globals
| Global | Description |
|---|---|
db |
Persistent storage (db.user, db.global, …) |
interaction |
Slash command / component interaction (when applicable) |
message |
Text message context (when applicable) |
client |
Discord client proxy |
guild, channel, member |
Context entities |
config |
Bot configuration (token stripped) |
variables |
Runtime variables object |
webhook |
Webhook payload context or null |
console |
log, info, warn, error, debug |
fetch |
HTTP requests (proxied) |
require(name) |
Whitelisted Node modules |
Quick example
const coins = await db.user.get('coins');
await db.user.set('coins', (Number(coins) || 0) + 10);
await interaction.reply(`You now have ${Number(coins) + 10} coins!`);
BDFD equivalent
Many BDJS features map to BDFD $functions. See the BDFD Variables category for $getUserVar, $setUserVar, and related functions.
Sections
- db — Storage API
- interaction — slash commands and replies
- Components — buttons, selects, modals
- Autocomplete — dynamic slash suggestions
- discord.js builders — embeds and UI components
- config and variables
- canvas and voice
- sandbox — limits and restrictions
- require()
- Placeholders
- Events & placeholders —
((...))in BDScript