Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/betterdiscord/betterdiscord/llms.txt

Use this file to discover all available pages before exploring further.

BdApi.Themes is a utility class for working with themes. It provides methods to enable, disable, reload, and retrieve theme instances.

Properties

folder

The path to the themes folder.
BdApi.Themes.folder: string
Example
console.log(BdApi.Themes.folder);
// Output: /path/to/BetterDiscord/themes

Methods

isEnabled

Determines if a particular theme is enabled.
BdApi.Themes.isEnabled(idOrFile: string): boolean
idOrFile
string
required
Theme ID or filename
Returns: boolean - true if the theme is enabled, false otherwise Example
if (BdApi.Themes.isEnabled("MyTheme")) {
  console.log("MyTheme is currently active");
}

enable

Enables the given theme.
BdApi.Themes.enable(idOrFile: string): void
idOrFile
string
required
Theme ID or filename
Example
BdApi.Themes.enable("DarkTheme");

disable

Disables the given theme.
BdApi.Themes.disable(idOrFile: string): void
idOrFile
string
required
Theme ID or filename
Example
BdApi.Themes.disable("DarkTheme");

toggle

Toggles whether a particular theme is enabled.
BdApi.Themes.toggle(idOrFile: string): void
idOrFile
string
required
Theme ID or filename
Example
// Toggle theme on/off
BdApi.Themes.toggle("DarkTheme");

reload

Reloads a particular theme if it is enabled.
BdApi.Themes.reload(idOrFile: string): void
idOrFile
string
required
Theme ID or filename
Example
// Reload theme to apply changes
BdApi.Themes.reload("DarkTheme");

get

Gets a particular theme instance.
BdApi.Themes.get(idOrFile: string): object | undefined
idOrFile
string
required
Theme ID or filename
Returns: object | undefined - The theme instance, or undefined if not found Example
const theme = BdApi.Themes.get("DarkTheme");
if (theme) {
  console.log(`Theme name: ${theme.name}`);
  console.log(`Theme author: ${theme.author}`);
  console.log(`Theme version: ${theme.version}`);
}

getAll

Gets all theme instances.
BdApi.Themes.getAll(): Array<object>
Returns: Array<object> - Array of all theme instances Example
const allThemes = BdApi.Themes.getAll();
console.log(`Total themes: ${allThemes.length}`);

allThemes.forEach(theme => {
  console.log(`${theme.name} by ${theme.author}`);
});

Common patterns

Switch between themes

function switchTheme(oldThemeId, newThemeId) {
  if (BdApi.Themes.isEnabled(oldThemeId)) {
    BdApi.Themes.disable(oldThemeId);
  }
  BdApi.Themes.enable(newThemeId);
}

// Usage
switchTheme("LightTheme", "DarkTheme");

List all enabled themes

const enabledThemes = BdApi.Themes.getAll()
  .filter(theme => BdApi.Themes.isEnabled(theme.id));

console.log("Active themes:", enabledThemes.map(t => t.name));

Auto-reload theme on changes

function setupThemeWatcher(themeId) {
  const fs = require("fs");
  const theme = BdApi.Themes.get(themeId);
  
  if (!theme) return;
  
  const themePath = `${BdApi.Themes.folder}/${theme.filename}`;
  
  fs.watch(themePath, () => {
    console.log(`Reloading ${theme.name}...`);
    BdApi.Themes.reload(themeId);
  });
}

Get theme metadata

function getThemeInfo(themeId) {
  const theme = BdApi.Themes.get(themeId);
  
  if (!theme) {
    return null;
  }
  
  return {
    name: theme.name,
    author: theme.author,
    version: theme.version,
    description: theme.description,
    enabled: BdApi.Themes.isEnabled(themeId)
  };
}