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.
UI is a utility class for creating user interfaces. It provides methods for showing modals, toasts, notices, and building settings panels.
Methods
alert
Shows a generic but very customizable modal.
BdApi . UI . alert ( "Warning" , "This action cannot be undone!" );
// With React elements
BdApi . UI . alert ( "Title" , [
"This is a " ,
BdApi . React . createElement ( "strong" , {}, "bold" ),
" message."
]);
content
string | ReactElement | Array<string | ReactElement>
required
Content to display in the modal. Can be a string, React element, or array of both.
showConfirmationModal
Shows a generic but very customizable confirmation modal with optional confirm and cancel callbacks.
BdApi . UI . showConfirmationModal ( "Delete Item" , "Are you sure you want to delete this?" , {
danger: true ,
confirmText: "Delete" ,
cancelText: "Cancel" ,
onConfirm : () => {
console . log ( "Item deleted" );
},
onCancel : () => {
console . log ( "Deletion cancelled" );
}
});
content
string | ReactElement | Array<string | ReactElement>
required
Single or mixed array of React elements and strings. Everything is wrapped in Discord’s TextElement component so strings will show and render properly.
Options to modify the modal. Whether the main button should be red or not.
Text for the confirmation/submit button.
Text for the cancel button.
Callback to occur when clicking the submit button.
Callback to occur when clicking the cancel button.
Callback to occur when exiting the modal.
Returns: string - The key used for this modal
showChangelogModal
Shows a changelog modal in a similar style to Discord’s. Customizable with images, videos, colored sections and supports markdown.
BdApi . UI . showChangelogModal ({
title: "My Plugin v2.0" ,
subtitle: "Major Update" ,
blurb: "This update brings exciting new features!" ,
banner: "https://example.com/banner.jpg" ,
changes: [
{
title: "New Features" ,
type: "added" ,
items: [
"Added dark mode support" ,
"Added user customization options"
]
},
{
title: "Bug Fixes" ,
type: "fixed" ,
items: [
"Fixed crash on startup" ,
"Fixed memory leak"
]
},
{
title: "Improvements" ,
type: "improved" ,
items: [
"Improved performance by 50%" ,
"Better error messages"
]
}
],
footer: "Thank you for using my plugin!"
});
Information to display in the modal. Title to show in the modal header.
Title to show below the main header.
Text to show in the body of the modal before the list of changes.
URL to an image to display as the banner of the modal.
YouTube link or URL of a video file to use as the banner.
URL to use for the video freeze-frame poster.
What to show in the modal footer.
List of changes to show. Each change object has:
title (string): Section title
type (string): One of “fixed”, “added”, “progress”, “improved”
items (Array<string>): List of change items
blurb (string, optional): Additional description
Returns: string - The key used for this modal
showInviteModal
Shows a modal for joining a guild like you would natively through Discord.
BdApi . UI . showInviteModal ( "discord-api" );
The Discord invite code (without the discord.gg/ part).
showToast
Shows a toast notification similar to Android towards the bottom of the screen.
BdApi . UI . showToast ( "Settings saved!" , { type: "success" });
BdApi . UI . showToast ( "An error occurred" , { type: "error" , timeout: 5000 });
The string to show in the toast.
Options for the toast. Changes the type of the toast stylistically and semantically. Choices: "", “info”, “success”, “danger”/“error”, “warning”/“warn”.
Determines whether the icon should show corresponding to the type. A toast without type will always have no icon.
Adjusts the time (in ms) the toast should be shown for before disappearing automatically.
Whether to force showing the toast and ignore the BetterDiscord setting.
showNotice
Shows a notice above Discord’s chat layer.
const close = BdApi . UI . showNotice ( "Update available!" , {
type: "info" ,
buttons: [
{
label: "Update Now" ,
onClick : () => {
console . log ( "Updating..." );
close ();
}
},
{
label: "Dismiss" ,
onClick : () => close ()
}
]
});
Options for the notice. Type for the notice. Will affect the color. Choices: “info”, “error”, “warning”, “success”.
buttons
Array<{label: string, onClick: function}>
Buttons that should be added next to the notice text.
Timeout until the notice is closed in milliseconds. Will not fire when set to 0.
Returns: function - A callback for closing the notice. Passing true as first parameter closes immediately without transitioning out
showNotification
Shows a system notification (if enabled in BetterDiscord settings).
BdApi . UI . showNotification ({
title: "New Message" ,
content: "You have a new message from John" ,
type: "info" ,
icon: "https://example.com/icon.png" ,
duration: 5000 ,
actions: [
{
text: "View" ,
callback : () => console . log ( "Viewing message" )
}
]
});
Notification configuration object. Title of the notification.
Content/body of the notification.
Type of notification. Choices: “info”, “success”, “warning”, “error”.
How long the notification should show in milliseconds.
URL to an icon to show in the notification.
actions
Array<{text: string, callback: function}>
Action buttons to show in the notification.
Creates a tooltip to automatically show on hover.
const button = document . querySelector ( ".my-button" );
const tooltip = BdApi . UI . createTooltip ( button , "Click me!" , {
side: "top" ,
style: "primary"
});
DOM node to monitor and show the tooltip on.
content
string | HTMLElement
required
String or HTML element to show in the tooltip.
Additional options for the tooltip. Correlates to the Discord styling/colors. Choices: “primary”, “info”, “success”, “warn”, “danger”.
Which side of the element to show the tooltip. Choices: “top”, “right”, “bottom”, “left”.
Prevents moving the tooltip to the opposite side if it is too big or goes offscreen.
Whether the tooltip should be disabled from showing on hover.
Returns: Tooltip - The tooltip that was generated
openDialog
Gives access to the Electron Dialog API. Returns a Promise that resolves to an object with the result.
// Open file dialog
const result = await BdApi . UI . openDialog ({
mode: "open" ,
openFile: true ,
filters: [{ name: "Images" , extensions: [ "png" , "jpg" , "gif" ]}]
});
if ( ! result . cancelled ) {
console . log ( "Selected files:" , result . filePaths );
}
// Save file dialog
const saveResult = await BdApi . UI . openDialog ({
mode: "save" ,
defaultPath: "~/my-file.txt"
});
if ( ! saveResult . cancelled ) {
console . log ( "Save to:" , saveResult . filePath );
}
Options object to configure the dialog. Determines whether the dialog should open or save files. Choices: “open”, “save”.
Path the dialog should show on launch.
filters
Array<{name: string, extensions: string[]}>
An array of file filters (e.g., [{name: "Images", extensions: ["png", "jpg"]}]).
showOverwriteConfirmation
Whether the user should be prompted when overwriting a file.
Whether hidden files should be shown in the dialog.
Whether the user should be prompted to create non-existent folders.
Whether the user should be able to select a directory as a target.
Whether the user should be able to select a file as a target.
Whether the user should be able to select multiple targets.
Whether the dialog should act as a modal to the main window.
Returns: Promise<object> - Promise that resolves to an object with:
cancelled (boolean): Whether the dialog was cancelled
filePath (string): Selected file path for save mode
filePaths (Array<string>): Selected file paths for open mode
buildSettingItem
Creates a single setting wrapped in a setting item that has a name and note.
const setting = BdApi . UI . buildSettingItem ({
type: "switch" ,
id: "enable-feature" ,
name: "Enable Feature" ,
note: "Turns the feature on or off" ,
value: true ,
onChange : ( value ) => {
console . log ( "Setting changed:" , value );
}
});
document . body . appendChild ( setting );
Setting configuration object. One of: “dropdown”, “number”, “switch”, “text”, “slider”, “radio”, “keybind”, “color”, “custom”.
Identifier to use for callbacks.
Visual description to display.
Current value of the setting.
Callback when the value changes (only argument is new value).
Whether this setting is disabled.
Whether the input should render inline with the name (false by default for radio type).
Only used for “custom” type.
Returns: A SettingItem React element with an input as the child
buildSettingsPanel
Creates a settings panel (React element) based on JSON-like data.
const panel = BdApi . UI . buildSettingsPanel ({
settings: [
{
type: "category" ,
id: "general" ,
name: "General Settings" ,
shown: true ,
settings: [
{
type: "switch" ,
id: "enabled" ,
name: "Enable Plugin" ,
note: "Turns the plugin on or off" ,
value: true
},
{
type: "text" ,
id: "username" ,
name: "Username" ,
note: "Your username" ,
value: "John"
}
]
},
{
type: "slider" ,
id: "volume" ,
name: "Volume" ,
note: "Adjust the volume" ,
value: 50 ,
min: 0 ,
max: 100
}
],
onChange : ( category , id , value ) => {
console . log ( `Setting changed: ${ category || 'root' } . ${ id } = ${ value } ` );
}
});
Panel configuration object. Array of settings to show. Each setting follows the same structure as buildSettingItem, with an additional “category” type that groups settings.
Function called on every change. Receives three arguments: category (null for root settings), id, and value.
Optionally used to save drawer states. Receives categoryId and current shown state.
Optionally used to recall drawer states. Receives categoryId and defaultShown state, should return the saved state.
Returns: React element usable for a settings panel
Examples
Complete settings panel
class MyPlugin {
getSettingsPanel () {
return BdApi . UI . buildSettingsPanel ({
settings: [
{
type: "category" ,
id: "appearance" ,
name: "Appearance" ,
settings: [
{
type: "switch" ,
id: "darkMode" ,
name: "Dark Mode" ,
note: "Enable dark mode" ,
value: this . settings . darkMode
},
{
type: "color" ,
id: "accentColor" ,
name: "Accent Color" ,
note: "Choose your accent color" ,
value: this . settings . accentColor
}
]
}
],
onChange : ( category , id , value ) => {
this . settings [ id ] = value ;
this . saveSettings ();
}
});
}
}
User feedback with toasts
function saveSettings () {
try {
// Save settings...
BdApi . UI . showToast ( "Settings saved!" , { type: "success" });
} catch ( error ) {
BdApi . UI . showToast ( "Failed to save settings" , { type: "error" });
}
}
Confirmation before destructive action
function deleteAllData () {
BdApi . UI . showConfirmationModal (
"Delete All Data" ,
"This will permanently delete all your data. This action cannot be undone." ,
{
danger: true ,
confirmText: "Delete Everything" ,
onConfirm : () => {
// Perform deletion
BdApi . UI . showToast ( "All data deleted" , { type: "success" });
}
}
);
}