### Setup BetterDiscord CLI Source: https://github.com/betterdiscord/cli/blob/main/README.md Clone the repository and install project dependencies using Task or Go. ```bash git clone https://github.com/BetterDiscord/cli.git cd cli task setup # Or: go mod download ``` -------------------------------- ### Get BetterDiscord Installation Singleton Source: https://context7.com/betterdiscord/cli/llms.txt Retrieve the global `BDInstall` struct for BetterDiscord's on-disk installation. This singleton is thread-safe and provides accessors for directories, download, prepare, and repair operations. You can also provide a custom base directory. ```go // Get the global BetterDiscord installation (singleton, thread-safe) bd := betterdiscord.GetInstallation() fmt.Println(bd.Root()) // e.g. /home/user/.config/BetterDiscord fmt.Println(bd.Data()) // /home/user/.config/BetterDiscord/data fmt.Println(bd.Plugins()) // /home/user/.config/BetterDiscord/plugins fmt.Println(bd.Themes()) // /home/user/.config/BetterDiscord/themes fmt.Println(bd.Asar()) // /home/user/.config/BetterDiscord/data/betterdiscord.asar // Check if installed if !bd.IsAsarInstalled() { log.Fatal("BetterDiscord is not installed") } // Read build metadata from the asar file buildinfo, err := bd.ReadBuildinfo() if err != nil { log.Fatal(err) } fmt.Println(buildinfo.Version) // "1.0.156" fmt.Println(buildinfo.Commit) // "a3f9e2b1d4c5" fmt.Println(buildinfo.Branch) // "master" fmt.Println(buildinfo.Mode) // "production" // Create directories and download asar if err := bd.Prepare(); err != nil { log.Fatal(err) } if err := bd.Download(); err != nil { log.Fatal(err) } // Remove the entire BetterDiscord installation folder if err := bd.RemoveAll(); err != nil { log.Fatal(err) } // Provide a custom base directory instead of the system default customBD := betterdiscord.GetInstallation("/tmp/test-config") fmt.Println(customBD.Root()) // /tmp/test-config/BetterDiscord ``` -------------------------------- ### Install BetterDiscord via bdcli Source: https://context7.com/betterdiscord/cli/llms.txt Installs BetterDiscord into a Discord installation. Supports specifying the release channel or an explicit path. Shows an example of mutually exclusive flags and the `reinstall` alias. ```bash # Install to Discord Stable (default channel) bdcli install --channel stable # ๐Ÿ›  Preparing BetterDiscord... # โœ… BetterDiscord prepared for install # ๐Ÿ“ฅ Downloading BetterDiscord... # โœ… Downloaded BetterDiscord version v1.0.156 from the official website # โœ… BetterDiscord downloaded # ๐Ÿ”Œ Injecting into Discord... # โœ… Injected into /home/user/.config/discord/0.0.90/modules/discord_desktop_core # โœ… Injection successful # ๐Ÿ”„ Restarting Discord... # โœ… Restarted Discord # โœ… BetterDiscord installed to /home/user/.config/discord/0.0.90/modules/discord_desktop_core # # ๐Ÿ“‹ Installation Summary: # Release Channel: Stable # Discord Version: 0.0.90 # Install Type: native # Core Path: /home/user/.config/discord/0.0.90/modules/discord_desktop_core # Install to Discord PTB bdcli install --channel ptb # Install to Discord Canary bdcli install --channel canary # Install to an explicit Discord path (Windows example) bdcli install --path "C:\\Users\\User\\AppData\\Local\\Discord" # Error: mutually exclusive flags bdcli install --channel stable --path /some/path # Error: --path and --channel are mutually exclusive # Alias: reinstall is identical to install bdcli reinstall --channel stable ``` -------------------------------- ### Install BetterDiscord CLI via npm Source: https://github.com/betterdiscord/cli/blob/main/README.md Installs the BetterDiscord CLI globally using npm. This is the recommended installation method. ```bash npm install -g @betterdiscord/cli ``` -------------------------------- ### Install BetterDiscord CLI via Go Source: https://github.com/betterdiscord/cli/blob/main/README.md Installs the BetterDiscord CLI using the Go build tools. Ensure Go is installed and configured on your system. ```bash go install github.com/betterdiscord/cli@latest ``` -------------------------------- ### Discover Discord Installations Source: https://context7.com/betterdiscord/cli/llms.txt Scans the filesystem for Discord installations, shows suggested install paths, and summarizes installed addons. The `installs` subcommand lists detected installations by default. ```bash # List all detected Discord installations (default when calling 'discover' without subcommand) bdcli discover installs # ๐Ÿ”Ž Discord installations: # # CHANNEL VERSION TYPE BD INJECTED PATH # Discord 0.0.90 native yes /home/user/.config/discord/0.0.90/modules/discord_desktop_core # Discord Canary 0.0.150 flatpak no /home/user/.var/app/com.discordapp.DiscordCanary/config/discordcanary/0.0.150/modules/discord_desktop_core ``` ```bash # Show suggested install paths for each channel bdcli discover paths # ๐Ÿงญ Suggested install paths: # # CHANNEL SUGGESTED PATH # Discord /home/user/.config/discord/0.0.90/modules/discord_desktop_core # Discord Canary /home/user/.var/app/com.discordapp.DiscordCanary/... # Discord PTB (none detected) ``` ```bash # Summarize installed plugins and themes bdcli discover addons # ๐Ÿงฉ Addons summary: # Plugins: 3 installed # - BetterVolume.plugin.js (/home/user/.config/BetterDiscord/plugins/BetterVolume.plugin.js) # - ShowHiddenChannels.plugin.js (...) # - ImageUtilities.plugin.js (...) # Themes: 1 installed # - Midnight.theme.css (...) ``` -------------------------------- ### Show BetterDiscord Installation Info Source: https://github.com/betterdiscord/cli/blob/main/README.md Displays detailed information about the current BetterDiscord installation, including version and installation path. ```bash bdcli info ``` -------------------------------- ### Discover Discord Installations and Resolve Paths Source: https://context7.com/betterdiscord/cli/llms.txt Scan platform-specific directories for Discord installations using `GetAllInstalls` or validate a single path with `ResolvePath`. `ResolvePath` returns a `DiscordInstall` struct with channel, version, and install-type metadata. You can also get the suggested path for a channel and manage BetterDiscord injection for a specific install. ```go // Scan all known paths and return map[DiscordChannel][]*DiscordInstall installs := discord.GetAllInstalls() for channel, list := range installs { for _, inst := range list { fmt.Printf("Channel: %s\n", inst.Channel.Name()) // "Discord", "Discord PTB", etc. fmt.Printf("Version: %s\n", inst.Version) // "0.0.90" fmt.Printf("Path: %s\n", inst.CorePath) fmt.Printf("Flatpak: %v, Snap: %v\n", inst.IsFlatpak, inst.IsSnap) fmt.Printf("BD Injected: %v\n", inst.IsInjected()) } } // Resolve (and validate) a specific path install := discord.ResolvePath("/home/user/.config/discord") if install == nil { log.Fatal("no valid Discord install found at that path") } // Get the suggested (highest version) path for a channel path := discord.GetSuggestedPath(models.Stable) fmt.Println(path) // "/home/user/.config/discord/0.0.90/modules/discord_desktop_core" // Install and uninstall BetterDiscord via a DiscordInstall if err := install.InstallBD(); err != nil { log.Fatal(err) } if err := install.UninstallBD(); err != nil { log.Fatal(err) } ``` -------------------------------- ### Install BetterDiscord to a Custom Discord Path Source: https://github.com/betterdiscord/cli/blob/main/README.md Installs BetterDiscord by specifying the exact path to a Discord installation using the --path flag. This is useful for non-standard Discord installations. ```bash bdcli install --path /path/to/Discord ``` -------------------------------- ### betterdiscord.GetInstallation() Source: https://context7.com/betterdiscord/cli/llms.txt Retrieves the global singleton instance of the BDInstall struct, which represents the on-disk installation of BetterDiscord. It provides methods to access installation paths, manage downloads, and prepare the environment. It can also be initialized with a custom base directory. ```APIDOC ## betterdiscord.GetInstallation() ### Description Returns the global `BDInstall` struct representing BetterDiscord's on-disk installation. Resolves the base directory from the OS config dir (or WSL Windows home). Exposes path accessors (`Root()`, `Data()`, `Plugins()`, `Themes()`, `Asar()`), download, prepare, and repair operations. ### Usage ```go // Get the global BetterDiscord installation (singleton, thread-safe) bd := betterdiscord.GetInstallation() fmt.Println(bd.Root()) // e.g. /home/user/.config/BetterDiscord fmt.Println(bd.Data()) // /home/user/.config/BetterDiscord/data fmt.Println(bd.Plugins()) // /home/user/.config/BetterDiscord/plugins fmt.Println(bd.Themes()) // /home/user/.config/BetterDiscord/themes fmt.Println(bd.Asar()) // /home/user/.config/BetterDiscord/data/betterdiscord.asar // Check if installed if !bd.IsAsarInstalled() { log.Fatal("BetterDiscord is not installed") } // Read build metadata from the asar file buildinfo, err := bd.ReadBuildinfo() if err != nil { log.Fatal(err) } fmt.Println(buildinfo.Version) // "1.0.156" fmt.Println(buildinfo.Commit) // "a3f9e2b1d4c5" fmt.Println(buildinfo.Branch) // "master" fmt.Println(buildinfo.Mode) // "production" // Create directories and download asar if err := bd.Prepare(); err != nil { log.Fatal(err) } if err := bd.Download(); err != nil { log.Fatal(err) } // Remove the entire BetterDiscord installation folder if err := bd.RemoveAll(); err != nil { log.Fatal(err) } // Provide a custom base directory instead of the system default customBD := betterdiscord.GetInstallation("/tmp/test-config") fmt.Println(customBD.Root()) // /tmp/test-config/BetterDiscord ``` ``` -------------------------------- ### Install bdcli via npm Source: https://context7.com/betterdiscord/cli/llms.txt Installs the bdcli binary globally using npm. Includes a verification step. ```bash # Recommended: installs the bdcli binary globally via npm npm install -g @betterdiscord/cli # Verify bdcli version # ๐Ÿ“ฆ BetterDiscord CLI v0.2.0 # ๐Ÿ”– Commit: abc1234 # ๐Ÿ•’ Built: 2025-01-15T12:00:00Z ``` -------------------------------- ### Show BetterDiscord Installation Info Source: https://context7.com/betterdiscord/cli/llms.txt Reads BetterDiscord build metadata and installation paths directly from the `betterdiscord.asar` file. An error message is displayed if BetterDiscord is not installed. ```bash bdcli info # ๐Ÿ“ฆ BetterDiscord Information: # Build Information: # ๐Ÿ”น Version: 1.0.156 # ๐Ÿ”น Commit: a3f9e2b1d4c5 # ๐Ÿ”น Branch: master # ๐Ÿ”น Mode: production # Installation Paths: # ๐Ÿ“ Base: /home/user/.config/BetterDiscord # โš™๏ธ Data: /home/user/.config/BetterDiscord/data # ๐Ÿ”Œ Plugins: /home/user/.config/BetterDiscord/plugins # ๐ŸŽจ Themes: /home/user/.config/BetterDiscord/themes ``` ```bash # Error when not installed bdcli info # Error: BetterDiscord does not appear to be installed, try running 'bdcli install' first ``` -------------------------------- ### discord.GetAllInstalls() / discord.ResolvePath() Source: https://context7.com/betterdiscord/cli/llms.txt Functions for discovering and validating Discord client installations. `GetAllInstalls` scans known locations for all installed Discord clients, returning them categorized by channel. `ResolvePath` validates a specific path and returns detailed information about the Discord installation found there. ```APIDOC ## discord.GetAllInstalls() / discord.ResolvePath() ### Description Scans platform-specific directories to discover Discord installations. `ResolvePath` validates a single path and returns a `DiscordInstall` struct with channel, version, and install-type metadata. ### Usage ```go // Scan all known paths and return map[DiscordChannel][]*DiscordInstall installs := discord.GetAllInstalls() for channel, list := range installs { for _, inst := range list { fmt.Printf("Channel: %s\n", inst.Channel.Name()) // "Discord", "Discord PTB", etc. fmt.Printf("Version: %s\n", inst.Version) // "0.0.90" fmt.Printf("Path: %s\n", inst.CorePath) fmt.Printf("Flatpak: %v, Snap: %v\n", inst.IsFlatpak, inst.IsSnap) fmt.Printf("BD Injected: %v\n", inst.IsInjected()) } } // Resolve (and validate) a specific path install := discord.ResolvePath("/home/user/.config/discord") if install == nil { log.Fatal("no valid Discord install found at that path") } // Get the suggested (highest version) path for a channel path := discord.GetSuggestedPath(models.Stable) fmt.Println(path) // "/home/user/.config/discord/0.0.90/modules/discord_desktop_core" // Install and uninstall BetterDiscord via a DiscordInstall if err := install.InstallBD(); err != nil { log.Fatal(err) } if err := install.UninstallBD(); err != nil { log.Fatal(err) } ``` ``` -------------------------------- ### List, Find, Install, Remove, and Update Local Addons Source: https://context7.com/betterdiscord/cli/llms.txt Manage local plugins and themes using functions like ListAddons, FindAddon, InstallAddon, RemoveAddon, and UpdateAddon. InstallAddon supports direct URLs, store names, or numeric store IDs. ```go // List installed plugins entries, err := betterdiscord.ListAddons(betterdiscord.AddonPlugin) if err != nil { log.Fatal(err) } for _, e := range entries { fmt.Printf("%s v%s by %s %.1fKB\n", e.Meta.Name, e.Meta.Version, e.Meta.Author, float64(e.Size)/1024.0) } // BetterVolume v1.3.0 by Zere 8.2KB // List installed themes themes, err := betterdiscord.ListAddons(betterdiscord.AddonTheme) ``` ```go // Find an installed addon by name, filename, or meta name (case-insensitive) entry := betterdiscord.FindAddon(betterdiscord.AddonPlugin, "BetterVolume") if entry != nil { fmt.Println(entry.Path) // "/home/user/.config/BetterDiscord/plugins/BetterVolume.plugin.js" fmt.Println(entry.Meta.Version) // "1.3.0" } ``` ```go // Install from store name resolved, err := betterdiscord.InstallAddon(betterdiscord.AddonPlugin, "BetterVolume") // Install from store ID resolved, err = betterdiscord.InstallAddon(betterdiscord.AddonPlugin, "84") // Install from URL resolved, err = betterdiscord.InstallAddon(betterdiscord.AddonPlugin, "https://raw.githubusercontent.com/zerebos/BetterVolume/main/BetterVolume.plugin.js") if err != nil { log.Fatal(err) } fmt.Println(resolved.Path) // full path to installed file fmt.Println(resolved.Store.Name) // store metadata (nil if installed via direct URL) ``` ```go // Remove an installed addon err = betterdiscord.RemoveAddon(betterdiscord.AddonPlugin, "BetterVolume") ``` ```go // Update (remove then reinstall) resolved, err = betterdiscord.UpdateAddon(betterdiscord.AddonTheme, "Midnight") ``` -------------------------------- ### Install BetterDiscord to Specific Discord Channels Source: https://github.com/betterdiscord/cli/blob/main/README.md Installs BetterDiscord to different Discord channels (Stable, PTB, Canary) using the --channel flag. Ensure the specified channel is installed on your system. ```bash bdcli install --channel stable ``` ```bash bdcli install --channel ptb ``` ```bash bdcli install --channel canary ``` -------------------------------- ### Install BetterDiscord CLI via Homebrew/Linuxbrew Source: https://github.com/betterdiscord/cli/blob/main/README.md Installs the BetterDiscord CLI on macOS or Linux using Homebrew or Linuxbrew. This command requires the respective package manager to be installed. ```bash brew install betterdiscord/tap/bdcli ``` -------------------------------- ### Get BetterDiscord CLI Help Source: https://github.com/betterdiscord/cli/blob/main/README.md Displays help information for the BetterDiscord CLI. Use --help with the main command or specific subcommands for detailed usage instructions. ```bash bdcli --help ``` ```bash bdcli [command] --help ``` -------------------------------- ### Install BetterDiscord CLI via winget (Windows) Source: https://github.com/betterdiscord/cli/blob/main/README.md Installs the BetterDiscord CLI on Windows using the winget package manager. This command is specific to Windows environments. ```bash winget install betterdiscord.cli ``` -------------------------------- ### Discover Discord Installations and Addons Source: https://github.com/betterdiscord/cli/blob/main/README.md Commands to discover installed Discord clients, their paths, and related addons. Useful for identifying where BetterDiscord can be managed. ```bash bdcli discover installs ``` ```bash bdcli discover paths ``` ```bash bdcli discover addons ``` -------------------------------- ### Manage Themes with bdcli Source: https://context7.com/betterdiscord/cli/llms.txt Commands for listing, installing, updating, and removing BetterDiscord themes. Themes can be installed by name or URL. ```bash bdcli themes list # NAME VERSION AUTHOR SIZE (KB) MODIFIED # Midnight 2.1.0 Gibbu 14.3 Nov 20, 2024 at 17:00 ``` ```bash bdcli themes install Midnight ``` ```bash bdcli themes install https://raw.githubusercontent.com/nicetransition/midnight/main/midnight.theme.css # โœ… Theme installed at /home/user/.config/BetterDiscord/themes/midnight.theme.css ``` ```bash bdcli themes update --all --check # ๐Ÿ” Checking for theme updates... # ๐Ÿ“ฆ Found 1 theme(s) with available updates: # โ€ข Midnight: v2.0.0 โ†’ v2.1.0 # ๐Ÿ’ก To install these updates, use: bdcli themes update --all (without --check) ``` ```bash bdcli themes update --all # โœ… Updated Midnight to v2.1.0 # ๐Ÿ“Š Summary: 1 updated, 0 failed ``` ```bash bdcli themes remove Midnight # โœ… Theme removed: Midnight ``` -------------------------------- ### Check BetterDiscord CLI Version Source: https://github.com/betterdiscord/cli/blob/main/README.md Displays the currently installed version of the BetterDiscord CLI. This is useful for verifying installation and checking for updates. ```bash bdcli version ``` -------------------------------- ### betterdiscord.FetchAddonFromStore() / FetchAddonsOfType() / SearchAddons() Source: https://context7.com/betterdiscord/cli/llms.txt Interacts with the BetterDiscord Store API to fetch addon information. `FetchAddonFromStore` retrieves a specific addon by its identifier. `FetchAddonsOfType` gets all addons of a specified type (plugins, themes, or all addons). `SearchAddons` performs client-side filtering of a given list of addons based on a search query. ```APIDOC ## betterdiscord.FetchAddonFromStore() / FetchAddonsOfType() / SearchAddons() ### Description Queries the BetterDiscord Store REST API (`https://api.betterdiscord.app/v3/store/`) and performs client-side search filtering. ### Usage ```go // Fetch a single addon by name or numeric ID string addon, err := betterdiscord.FetchAddonFromStore("BetterVolume") if err != nil { log.Fatal(err) } fmt.Println(addon.ID) // 84 fmt.Println(addon.Name) // "BetterVolume" fmt.Println(addon.Version) // "1.3.0" fmt.Println(addon.Type) // "plugin" fmt.Println(addon.Description) // "Allows you to set volume above 200%" fmt.Println(addon.Downloads) // 125000 fmt.Println(addon.LatestSourceURL) // "https://raw.githubusercontent.com/..." fmt.Println(addon.Author.DisplayName) // "Zere" fmt.Println(addon.Author.GitHubName) // "zerebos" // Fetch all plugins from the store plugins, err := betterdiscord.FetchAddonsOfType("plugins") if err != nil { log.Fatal(err) } // Fetch all themes themes, err := betterdiscord.FetchAddonsOfType("themes") // Fetch everything (plugins + themes) all, err := betterdiscord.FetchAddonsOfType("addons") // Client-side search across name, description, author, filename results := betterdiscord.SearchAddons(plugins, "volume") for _, r := range results { fmt.Printf("%d %s v%s by %s (%d downloads)\n", r.ID, r.Name, r.Version, r.Author.DisplayName, r.Downloads) } // 84 BetterVolume v1.3.0 by Zere (125000 downloads) ``` ``` -------------------------------- ### Manage Plugins with bdcli Source: https://context7.com/betterdiscord/cli/llms.txt Commands for updating, removing, and managing BetterDiscord plugins. Use `--all` to affect all installed plugins. ```bash bdcli plugins update BetterVolume # โœ… Plugin updated at /home/user/.config/BetterDiscord/plugins/BetterVolume.plugin.js ``` ```bash bdcli plugins update --all # ๐Ÿ” Checking for plugin updates... # ๐Ÿ“ฆ Found 2 plugin(s) with available updates: # โ€ข BetterVolume: v1.2.0 โ†’ v1.3.0 # โ€ข ImageUtilities: v5.1.0 โ†’ v5.2.0 # โœ… Updated BetterVolume to v1.3.0 # โœ… Updated ImageUtilities to v5.2.0 # ๐Ÿ“Š Summary: 2 updated, 0 failed ``` ```bash bdcli plugins remove BetterVolume # โœ… Plugin removed: BetterVolume ``` ```bash bdcli plugins remove NonExistentPlugin # โŒ Plugin 'NonExistentPlugin' is not installed. ``` -------------------------------- ### Manage BetterDiscord Plugins Source: https://context7.com/betterdiscord/cli/llms.txt Provides full lifecycle management for plugins, including listing, showing details, installing by name/ID/URL, updating, and removing. Plugin files use the `.plugin.js` extension. ```bash # List all installed plugins bdcli plugins list # NAME VERSION AUTHOR SIZE (KB) MODIFIED # BetterVolume 1.3.0 Zere 8.2 Jan 5, 2025 at 14:32 # ShowHiddenChannels 3.2.1 DevilBro 24.1 Dec 12, 2024 at 09:15 ``` ```bash # Show detailed info for an installed plugin bdcli plugins info BetterVolume # ๐Ÿ“ฆ BetterVolume v1.3.0 # By: Zere (https://github.com/zerebos) # Allows you to set the volume of users above 200% # ๐Ÿ“ File: BetterVolume.plugin.js # ๐Ÿ’พ Size: 8.2 KB # ๐Ÿ• Modified: Jan 5, 2025 at 14:32 # ๐ŸŒ Website: https://betterdiscord.app/plugin/BetterVolume # ๐Ÿ”— Source: https://raw.githubusercontent.com/... ``` ```bash # Install a plugin by store name bdcli plugins install BetterVolume ``` ```bash # Install a plugin by store ID bdcli plugins install 84 ``` ```bash # Install from a direct URL bdcli plugins install https://raw.githubusercontent.com/zerebos/BetterVolume/main/BetterVolume.plugin.js # โœ… Plugin installed at /home/user/.config/BetterDiscord/plugins/BetterVolume.plugin.js ``` ```bash # Check for a plugin update without installing bdcli plugins update BetterVolume --check # ๐Ÿ“ฆ Update available for 'BetterVolume' ``` -------------------------------- ### Manage BetterDiscord Plugins Source: https://github.com/betterdiscord/cli/blob/main/README.md Commands for managing plugins, including listing, installing, updating, and removing them. Plugins can be identified by name, ID, or URL. ```bash bdcli plugins list ``` ```bash bdcli plugins info ``` ```bash bdcli plugins install ``` ```bash bdcli plugins update ``` ```bash bdcli plugins update --check ``` ```bash bdcli plugins remove ``` -------------------------------- ### Get bdcli Version Source: https://context7.com/betterdiscord/cli/llms.txt Prints the BetterDiscord CLI version, commit hash, and build date. For development builds, it shows Go runtime build info. ```bash bdcli version # ๐Ÿ“ฆ BetterDiscord CLI v0.2.0 # ๐Ÿ”– Commit: abc1234f # ๐Ÿ•’ Built: 2025-01-15T12:00:00Z ``` ```bash bdcli version # * build info output from runtime/debug.ReadBuildInfo() * ``` -------------------------------- ### Uninstall BetterDiscord from All Installations Source: https://github.com/betterdiscord/cli/blob/main/README.md Uninstalls BetterDiscord from all detected Discord installations on the system without deleting any BetterDiscord data. Use with caution. ```bash bdcli uninstall --all ``` -------------------------------- ### Manage BetterDiscord Themes Source: https://github.com/betterdiscord/cli/blob/main/README.md Commands for managing themes, including listing, installing, updating, and removing them. Themes can be identified by name, ID, or URL. ```bash bdcli themes list ``` ```bash bdcli themes info ``` ```bash bdcli themes install ``` ```bash bdcli themes update ``` ```bash bdcli themes update --check ``` ```bash bdcli themes remove ``` -------------------------------- ### Detect WSL and Convert Paths Source: https://context7.com/betterdiscord/cli/llms.txt Check if running under WSL, get Windows home directory, and convert paths between Windows and WSL formats. Can also execute Windows commands from WSL. ```go // Check if currently running under WSL if wsl.IsWSL() { fmt.Println("Running under WSL") // Get the Windows home directory as a WSL path (e.g., /mnt/c/Users/Username) winHome, err := wsl.WindowsHome() if err == nil { fmt.Println(winHome) // "/mnt/c/Users/Username" } // Convert Windows path to WSL path wslPath, err := wsl.ToWSLPath(`C:\\Users\\Username\\AppData\\Local\\Discord`) fmt.Println(wslPath) // "/mnt/c/Users/Username/AppData/Local/Discord" // Convert WSL path to Windows path winPath, err := wsl.ToWindowsPath("/mnt/c/Users/Username") fmt.Println(winPath) // "C:\\Users\\Username" // Run a Windows command from WSL result, err := wsl.ExecWindows("echo %USERPROFILE%") fmt.Println(result) // "C:\\Users\\Username" // Access full WSL info struct info := wsl.Info() fmt.Println(info.DistroName) // "Ubuntu-22.04" fmt.Println(info.KernelVersion) // "...microsoft-standard-WSL2..." } ``` -------------------------------- ### Fully Uninstall BetterDiscord Source: https://github.com/betterdiscord/cli/blob/main/README.md Completely uninstalls BetterDiscord from all Discord installations and removes all associated BetterDiscord data folders. This is a comprehensive removal. ```bash bdcli uninstall --full ``` -------------------------------- ### Update BetterDiscord Source: https://github.com/betterdiscord/cli/blob/main/README.md Updates BetterDiscord to the latest available version. The --check flag can be used to check for updates without performing the installation. ```bash bdcli update ``` ```bash bdcli update --check ``` -------------------------------- ### Uninstall BetterDiscord via bdcli Source: https://context7.com/betterdiscord/cli/llms.txt Removes BetterDiscord injection from Discord. Supports uninjecting from a specific channel/path, all detected installs, or a full wipe. ```bash # Uninject from Discord Stable bdcli uninstall --channel stable # ๐Ÿงน Removing injection... # โœ… Removed from Discord # ๐Ÿ”„ Restarting Discord... # โœ… Restarted Discord # โœ… BetterDiscord uninstalled from /home/user/.config/discord/0.0.90/modules/discord_desktop_core # Uninject from all detected Discord installs (keeps BetterDiscord data folders) bdcli uninstall --all # ๐Ÿงน Removing injection... # โœ… Removed from Discord # โœ… Removed from Discord Canary # ๐Ÿ”„ Restarting Discord... # โœ… BetterDiscord uninjected from all Discord instances ``` -------------------------------- ### Uninstall BetterDiscord from a Custom Discord Path Source: https://github.com/betterdiscord/cli/blob/main/README.md Uninstalls BetterDiscord from a specific Discord installation path provided via the --path flag. This command removes BetterDiscord without deleting user data. ```bash bdcli uninstall --path /path/to/Discord ``` -------------------------------- ### Build bdcli from source Source: https://context7.com/betterdiscord/cli/llms.txt Clones the repository, downloads Go modules, and builds the bdcli binary for the current platform. Also shows how to use the Task runner for building. ```bash git clone https://github.com/BetterDiscord/cli.git cd cli go mod download # Build for current platform go build -ldflags "-X main.version=v0.2.0 -X main.commit=$(git rev-parse --short HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o bdcli . # Or use Task runner task build ``` -------------------------------- ### Run BetterDiscord CLI Locally Source: https://github.com/betterdiscord/cli/blob/main/README.md Execute the CLI directly using 'go run' or via the 'task run' command, passing arguments as needed. ```bash # Run directly go run main.go install stable # Or use Task task run -- install stable ``` -------------------------------- ### Download File and Inspect Response Headers Source: https://context7.com/betterdiscord/cli/llms.txt Use `utils.DownloadFile` to save a file to disk. The function returns the `*http.Response` object, allowing access to response headers like 'x-bd-version'. ```go // Download a file to disk; returns the *http.Response (for header inspection) resp, err := utils.DownloadFile( "https://betterdiscord.app/Download/betterdiscord.asar", "/home/user/.config/BetterDiscord/data/betterdiscord.asar", ) if err != nil { log.Fatal(err) } // Access response headers (e.g., version sent by BetterDiscord server) version := resp.Header.Get("x-bd-version") fmt.Println(version) // "1.0.156" ``` -------------------------------- ### Fetch and Search Addons from BetterDiscord Store Source: https://context7.com/betterdiscord/cli/llms.txt Query the BetterDiscord Store API to fetch specific addons by name or ID, retrieve all addons of a certain type (plugins, themes, or all), or perform client-side searches across multiple criteria. Requires the addon name or ID for single fetches and a list of addons for searching. ```go // Fetch a single addon by name or numeric ID string addon, err := betterdiscord.FetchAddonFromStore("BetterVolume") if err != nil { log.Fatal(err) } fmt.Println(addon.ID) // 84 fmt.Println(addon.Name) // "BetterVolume" fmt.Println(addon.Version) // "1.3.0" fmt.Println(addon.Type) // "plugin" fmt.Println(addon.Description) // "Allows you to set volume above 200%" fmt.Println(addon.Downloads) // 125000 fmt.Println(addon.LatestSourceURL) // "https://raw.githubusercontent.com/..." fmt.Println(addon.Author.DisplayName) // "Zere" fmt.Println(addon.Author.GitHubName) // "zerebos" // Fetch all plugins from the store plugins, err := betterdiscord.FetchAddonsOfType("plugins") if err != nil { log.Fatal(err) } // Fetch all themes themes, err := betterdiscord.FetchAddonsOfType("themes") // Fetch everything (plugins + themes) all, err := betterdiscord.FetchAddonsOfType("addons") // Client-side search across name, description, author, filename results := betterdiscord.SearchAddons(plugins, "volume") for _, r := range results { fmt.Printf("%d %s v%s by %s (%d downloads)\n", r.ID, r.Name, r.Version, r.Author.DisplayName, r.Downloads) } // 84 BetterVolume v1.3.0 by Zere (125000 downloads) ``` -------------------------------- ### Contributing to BetterDiscord CLI Source: https://github.com/betterdiscord/cli/blob/main/README.md Steps for contributing to the project, including forking, creating branches, committing changes, and opening pull requests. ```bash git checkout -b feature/amazing-feature git commit -m 'feat: add amazing feature' git push origin feature/amazing-feature ``` -------------------------------- ### Build BetterDiscord CLI Source: https://github.com/betterdiscord/cli/blob/main/README.md Compile the CLI for the current platform or for all supported platforms using 'task build:all'. ```bash # Build for current platform task build # Build for all platforms task build:all # Output will be in ./dist/ ``` -------------------------------- ### BetterDiscord CLI Project Structure Source: https://github.com/betterdiscord/cli/blob/main/README.md Overview of the directory structure for the BetterDiscord CLI project, highlighting key packages and files. ```tree . โ”œโ”€โ”€ cmd/ # Cobra commands โ”‚ โ”œโ”€โ”€ install.go # Install command โ”‚ โ”œโ”€โ”€ update.go # Update command โ”‚ โ”œโ”€โ”€ info.go # Info command โ”‚ โ”œโ”€โ”€ discover.go # Discover command โ”‚ โ”œโ”€โ”€ plugins.go # Plugins commands โ”‚ โ”œโ”€โ”€ themes.go # Themes commands โ”‚ โ”œโ”€โ”€ store.go # Store commands โ”‚ โ”œโ”€โ”€ uninstall.go # Uninstall command โ”‚ โ”œโ”€โ”€ version.go # Version command โ”‚ โ””โ”€โ”€ root.go # Root command โ”œโ”€โ”€ internal/ # Internal packages โ”‚ โ”œโ”€โ”€ betterdiscord/ # BetterDiscord installation logic โ”‚ โ”œโ”€โ”€ discord/ # Discord path resolution and injection โ”‚ โ”œโ”€โ”€ models/ # Data models โ”‚ โ””โ”€โ”€ utils/ # Utility functions โ”œโ”€โ”€ main.go # Entry point โ”œโ”€โ”€ Taskfile.yml # Task automation โ””โ”€โ”€ .goreleaser.yaml # Release configuration ``` -------------------------------- ### Publish to npm Source: https://github.com/betterdiscord/cli/blob/main/README.md After a successful release build and draft creation on GitHub, publish the package to the npm registry. ```bash npm publish ``` -------------------------------- ### DownloadFile and DownloadJSON Source: https://context7.com/betterdiscord/cli/llms.txt These functions provide low-level HTTP utilities for downloading files and JSON data. They both set a custom User-Agent and use a 10-second timeout. `DownloadFile` saves content to disk and returns the HTTP response, while `DownloadJSON` fetches and deserializes JSON into a specified generic type. ```APIDOC ## DownloadFile and DownloadJSON ### Description Low-level HTTP helpers used throughout the codebase. Both set `User-Agent: BetterDiscord/cli` and use a 10-second timeout. ### Usage #### `utils.DownloadFile()` ```go // Download a file to disk; returns the *http.Response (for header inspection) resp, err := utils.DownloadFile( "https://betterdiscord.app/Download/betterdiscord.asar", "/home/user/.config/BetterDiscord/data/betterdiscord.asar", ) if err != nil { log.Fatal(err) } // Access response headers (e.g., version sent by BetterDiscord server) version := resp.Header.Get("x-bd-version") fmt.Println(version) // "1.0.156" ``` #### `utils.DownloadJSON[T]()` ```go // Fetch and deserialize JSON into any type using generics type ReleaseAsset struct { Name string `json:"name"` URL string `json:"url"` } type Release struct { TagName string `json:"tag_name"` Assets []ReleaseAsset `json:"assets"` } release, err := utils.DownloadJSON[Release]( "https://api.github.com/repos/BetterDiscord/BetterDiscord/releases/latest", ) if err != nil { log.Fatal(err) } fmt.Println(release.TagName) // "v1.0.156" fmt.Println(release.Assets[0].Name) // "betterdiscord.asar" ``` ``` -------------------------------- ### List Available Tasks Source: https://github.com/betterdiscord/cli/blob/main/README.md View all available automation tasks defined in the Taskfile.yml. ```bash # Development task run # Run the CLI (pass args with: task run -- install stable) # Building task build # Build for current platform task build:all # Build for all platforms (GoReleaser) # Testing task test # Run tests task test:verbose # Run tests with verbose output task coverage # Run tests with coverage summary task coverage:html # Generate HTML coverage report # Code Quality task fmt # Format Go files task vet # Run go vet task lint # Run golangci-lint task check # Run fix, fmt, vet, lint, test # Release task release:snapshot # Test release build task release # Create release (requires tag) # Cleaning task clean # Remove build and debug artifacts ``` -------------------------------- ### BetterDiscord CLI Help Output Source: https://github.com/betterdiscord/cli/blob/main/README.md Displays the general help output for the BetterDiscord CLI, listing available commands and global flags. This provides an overview of the CLI's capabilities. ```text A cross-platform CLI for installing, updating, and managing BetterDiscord. Usage: bdcli [flags] bdcli [command] Available Commands: completion Generate shell completions discover Discover Discord installations and related data help Help about any command info Displays information about BetterDiscord installation install Installs BetterDiscord to your Discord plugins Manage BetterDiscord plugins store Browse and search the BetterDiscord store themes Manage BetterDiscord themes uninstall Uninstalls BetterDiscord from your Discord update Update BetterDiscord to the latest version version Print the version number Flags: --silent Suppress non-error output -h, --help help for bdcli Use "bdcli [command] --help" for more information about a command. ``` -------------------------------- ### BetterDiscord CLI Global Options Source: https://github.com/betterdiscord/cli/blob/main/README.md Demonstrates how to use the --silent flag to suppress non-error output from the CLI. This is useful for scripting and automation. ```bash bdcli --silent ``` -------------------------------- ### Test BetterDiscord CLI Source: https://github.com/betterdiscord/cli/blob/main/README.md Execute all unit tests using 'task test' or run tests with code coverage reporting using 'task coverage'. ```bash # Run all tests task test # Run with coverage task coverage ``` -------------------------------- ### BetterDiscord CLI Automation with Silent Output Source: https://github.com/betterdiscord/cli/blob/main/README.md Demonstrates how to use the --silent flag or the BDCLI_SILENT environment variable to suppress non-error output for scripting and automation purposes. ```bash # One-off command bdcli --silent install --channel stable ``` ```bash # Environment variable (applies to all commands) BDCLI_SILENT=1 bdcli update ``` -------------------------------- ### Browse BetterDiscord Store with bdcli Source: https://context7.com/betterdiscord/cli/llms.txt Search and view details for plugins and themes available in the BetterDiscord store. Supports searching by query, name, or ID. ```bash bdcli store search "volume" # ID NAME TYPE VERSION AUTHOR DOWNLOADS # 84 BetterVolume plugin 1.3.0 Zere 125000 ``` ```bash bdcli store show BetterVolume # ๐Ÿ“ฆ BetterVolume v1.3.0 [PLUGIN] # By: Zere (github.com/zerebos) # Allows you to set the volume of users above 200% # # ๐Ÿ“Š Downloads: 125000 | ๐Ÿ‘ Likes: 3200 # ๐Ÿท๏ธ Tags: audio, volume, utility # # ๐Ÿ“… Released: Mar 10, 2021 at 09:00 # ๐Ÿ”„ Updated: Jan 5, 2025 at 14:30 # ๐Ÿ”— Source: https://raw.githubusercontent.com/zerebos/BetterVolume/main/BetterVolume.plugin.js ``` ```bash bdcli store show 84 ``` ```bash bdcli store plugins search "image" # ID NAME VERSION AUTHOR DOWNLOADS # 102 ImageUtilities 5.2.0 DevilBro 200000 ``` ```bash bdcli store plugins show ImageUtilities ``` ```bash bdcli store themes search "dark" # ID NAME VERSION AUTHOR DOWNLOADS # 12 Midnight 2.1.0 Gibbu 80000 ``` ```bash bdcli store themes show Midnight ``` -------------------------------- ### Browse BetterDiscord Store Source: https://github.com/betterdiscord/cli/blob/main/README.md Commands to search for and view items in the BetterDiscord store, including plugins and themes. Items can be identified by ID or name. ```bash bdcli store search ``` ```bash bdcli store show ``` ```bash bdcli store plugins search ``` ```bash bdcli store plugins show ``` ```bash bdcli store themes search ``` ```bash bdcli store themes show ``` -------------------------------- ### Create Git Tag for Release Source: https://github.com/betterdiscord/cli/blob/main/README.md Tag a specific commit for release, then push the tag to the remote repository to trigger the automated release process. ```bash git tag -a v0.2.0 -m "Release v0.2.0" git push origin v0.2.0 ``` -------------------------------- ### Fetch and Deserialize JSON with Generics Source: https://context7.com/betterdiscord/cli/llms.txt Use `utils.DownloadJSON[T]` to fetch and deserialize JSON data into a specified Go type using generics. This is useful for parsing API responses. ```go // Fetch and deserialize JSON into any type using generics type ReleaseAsset struct { Name string `json:"name"` URL string `json:"url"` } type Release struct { TagName string `json:"tag_name"` Assets []ReleaseAsset `json:"assets"` } release, err := utils.DownloadJSON[Release]( "https://api.github.com/repos/BetterDiscord/BetterDiscord/releases/latest", ) if err != nil { log.Fatal(err) } fmt.Println(release.TagName) // "v1.0.156" fmt.Println(release.Assets[0].Name) // "betterdiscord.asar" ``` -------------------------------- ### Uninstall BetterDiscord Source: https://context7.com/betterdiscord/cli/llms.txt Use the `--full` flag to remove all BetterDiscord data and uninject from all Discord instances. For specific uninstallation, use the `--path` flag with the Discord configuration directory. ```bash bdcli uninstall --full # โœ… BetterDiscord fully uninstalled from all Discord instances ``` ```bash # Uninject from a specific path bdcli uninstall --path "/home/user/.var/app/com.discordapp.Discord/config/discord" ``` ```bash # Error: conflicting flags bdcli uninstall --full --all # Error: --full and --all are mutually exclusive ``` -------------------------------- ### Generate Shell Completions Source: https://github.com/betterdiscord/cli/blob/main/README.md Generates shell completion scripts for bash, zsh, and fish shells. This enhances the command-line experience by providing auto-completion. ```bash bdcli completion bash ``` ```bash bdcli completion zsh ``` ```bash bdcli completion fish ``` -------------------------------- ### Generate Shell Completions with bdcli Source: https://context7.com/betterdiscord/cli/llms.txt Generates shell completion scripts for Bash, Zsh, Fish, and PowerShell. Add the output to your shell's configuration files. ```bash # Bash: add to ~/.bashrc or source directly bdcli completion bash > /etc/bash_completion.d/bdcli # or source <(bdcli completion bash) ``` ```bash # Zsh: add to fpath bdcli completion zsh > "${fpath[1]}/_bdcli" ``` ```bash # Fish bdcli completion fish > ~/.config/fish/completions/bdcli.fish ``` ```bash # PowerShell bdcli completion powershell | Out-String | Invoke-Expression ``` -------------------------------- ### Parse Addon Metadata with parseJSDoc Source: https://context7.com/betterdiscord/cli/llms.txt Extracts JSDoc-style metadata from plugin and theme source files. The parsed Meta struct is accessible via ListAddons results. ```go // Example plugin file header: // /** // * @name BetterVolume // * @author Zere // * @description Allows you to set the volume of users above 200% // * @version 1.3.0 // * @website https://betterdiscord.app/plugin/BetterVolume // * @source https://raw.githubusercontent.com/zerebos/BetterVolume/main/BetterVolume.plugin.js // * @invite BJPcQFh // */ // parseJSDoc is called internally by ListAddons when scanning plugin/theme files. // The resulting Meta struct is available on every AddonEntry: entries, _ := betterdiscord.ListAddons(betterdiscord.AddonPlugin) for _, e := range entries { fmt.Println(e.Meta.Name) // "BetterVolume" fmt.Println(e.Meta.Author) // "Zere" fmt.Println(e.Meta.Version) // "1.3.0" fmt.Println(e.Meta.Description) // "Allows you to set the volume of users above 200%" fmt.Println(e.Meta.Website) // "https://betterdiscord.app/plugin/BetterVolume" fmt.Println(e.Meta.Source) // "https://raw.githubusercontent.com/..." fmt.Println(e.Meta.Invite) // "BJPcQFh" } ``` -------------------------------- ### Validate URL Format Source: https://context7.com/betterdiscord/cli/llms.txt The `utils.IsURL` function checks if a given string is a valid URL format. It returns `true` for valid URLs and `false` otherwise. ```go // Check if a string is a valid URL fmt.Println(utils.IsURL("https://example.com/plugin.js")) // true fmt.Println(utils.IsURL("MyPlugin")) // false fmt.Println(utils.IsURL("84")) // false ```