Skip to main content
BetterDiscord plugins are JavaScript files that extend Discord’s functionality. This guide will walk you through creating your first plugin.

Prerequisites

Before you start developing plugins, make sure you have:
  • BetterDiscord installed
  • A text editor (VS Code, Sublime Text, etc.)
  • Basic knowledge of JavaScript
  • Familiarity with Discord’s interface

Your first plugin

1

Create the plugin file

Navigate to your BetterDiscord plugins folder and create a new file named MyFirstPlugin.plugin.js.The plugins folder location varies by platform:
  • Windows: %appdata%/BetterDiscord/plugins
  • macOS: ~/Library/Application Support/BetterDiscord/plugins
  • Linux: ~/.config/BetterDiscord/plugins
2

Add the plugin structure

Create a basic plugin structure with the required metadata and lifecycle methods:
MyFirstPlugin.plugin.js
/**
 * @name MyFirstPlugin
 * @description My first BetterDiscord plugin
 * @version 1.0.0
 * @author YourName
 */

module.exports = class MyFirstPlugin {
    start() {
        console.log("MyFirstPlugin has started!");
    }
    
    stop() {
        console.log("MyFirstPlugin has stopped!");
    }
};
3

Enable the plugin

Open Discord and navigate to User Settings > Plugins. You should see your plugin listed. Toggle it on to activate it.
4

Verify it works

Open Discord’s developer console (Ctrl+Shift+I or Cmd+Option+I) and check the Console tab. You should see “MyFirstPlugin has started!” when the plugin is enabled.

Using BdApi

BetterDiscord provides a global BdApi object that gives you access to various utilities. Here’s an example that shows a toast notification:
module.exports = class MyFirstPlugin {
    start() {
        BdApi.UI.showToast("MyFirstPlugin started!", { type: "success" });
    }
    
    stop() {
        BdApi.UI.showToast("MyFirstPlugin stopped!", { type: "info" });
    }
};

Accessing plugin information

You can create a plugin-specific BdApi instance by passing your plugin name to the constructor:
module.exports = class MyFirstPlugin {
    constructor() {
        this.api = new BdApi("MyFirstPlugin");
    }
    
    start() {
        // Now API calls are automatically bound to your plugin
        this.api.Logger.info("Plugin started");
        
        // Save some data
        this.api.Data.save("myKey", { value: "Hello World" });
    }
    
    stop() {
        // Load the saved data
        const data = this.api.Data.load("myKey");
        this.api.Logger.info("Saved data:", data);
    }
};

Adding interactivity

Here’s a simple plugin that adds a button to show an alert:
module.exports = class InteractivePlugin {
    start() {
        // Patch a React component to add a button
        const {React} = BdApi;
        
        BdApi.UI.showToast("Interactive plugin loaded!", {
            type: "success",
            timeout: 3000
        });
    }
    
    stop() {
        BdApi.Patcher.unpatchAll("InteractivePlugin");
    }
};

Next steps

Plugin structure

Learn about plugin metadata, exports, and file organization

BdApi overview

Explore the complete BdApi and its namespaces

Settings

Add configurable settings to your plugin

Best practices

Follow best practices for reliable plugins

Build docs developers (and LLMs) love