BdApi is a globally accessible object (window.BdApi) for use by plugins and developers. It provides a comprehensive set of tools for interacting with Discord’s internals and creating powerful plugins.
Accessing BdApi
There are two ways to access BdApi:Global access
You can access the global API directly:Plugin-scoped instance
When creating a plugin, you can get a scoped instance by passing your plugin name to the constructor. This automatically binds certain namespaces to your plugin:Patcher- All patches are tracked under your plugin nameData- Data is saved/loaded under your plugin nameDOM- Styles use your plugin name as the default IDLogger- Logs are prefixed with your plugin nameCommands- Commands are registered under your pluginHooks- React hooks are scoped to your plugin
API namespaces
Core modules
Patcher
Modify existing functions with before, instead, and after patches
Webpack
Search for and retrieve Discord’s internal modules
Data
Save and load persistent plugin data
DOM
Manipulate the DOM and inject styles
UI
Create modals, toasts, notices, and settings panels
Additional namespaces
- React - The React module used inside Discord
- ReactDOM - The ReactDOM module used inside Discord
- ReactUtils - Utilities for working with React components
- Utils - General utility functions
- Components - Pre-built React components for common UI elements
- ContextMenu - Tools for working with Discord’s context menus
- Plugins - Manage installed plugins
- Themes - Manage installed themes
- Commands - Register custom slash commands
- Net - Network utilities including
fetch - Logger - Logging utilities
- Hooks - React hooks
Properties
A reference string for BetterDiscord’s current version.