Skip to content
Zack edited this page Jan 16, 2019 · 34 revisions

For the time being, you'll have to build BDv2 locally by yourself.

Table of Contents

Requirements

  • Node.js v6 or later
  • libsecret if using Linux

Release

Follow these instructions if you want to test how BDv2 would run when it's released to the public, it's also preferred to use this when you're developing a theme or a plugin.

This will also generate a zip archive for the installer.

  1. Clone the repository.
  2. Run npm install and npm run release in the root folder.
    This will delete the release directory, including any user data, rebuild it and copy the node-sass and keytar bindings.
  3. Download the emote data and extract the contents to release/data.
    You can skip this step if you don't want to see emotes.
  4. Modify Discord to load BetterDiscord.

To rebuild the release, run npx gulp build-release.

Development

Follow these instructions if you're going to set up a development environment for BDv2.

  1. Clone the repository.
  2. Run npm install and npm run build in the root folder.
  3. Download the emote data and extract the contents to tests/data.
    You can skip this step if you don't want to see emotes.
  4. Modify Discord to load BetterDiscord.

To rebuild all, run npm run build.
To watch the core, run npm run watch_core.
To watch the client, run npm run watch_client.
To watch the CSS editor, run npm run watch_csseditor.

Core rebuilds requires a full Discord restart, while client and CSS editor can be reloaded by pressing Ctrl/Cmd + R.

Injecting

There's 3 ways that you can take, the first one by using the inject script and the second and third one being manual injection.

Using the provided script

Run npm run inject in the root folder.

If you want to install to other release channels like PTB and Canary, you can run npm run inject ptb or npm run inject canary.

The script injects the same way as the instructions below for injecting through resources.

Injecting through resources

  1. Navigate to the resources folder and create a new folder called app.

    This is usually located at:

    • for Windows, %localappdata%\Discord\app-<version>\resources
    • for macOS, /Applications/Discord.app/Contents/Resources
    • for Linux, /usr/share/discord/resources
  2. Inside the folder, create the following files:

    • package.json
      {
        "name": "betterdiscord",
        "description": "BetterDiscord",
        "main": "index.js",
        "private": true,
        "dependencies": {}
      }
    • index.js
      const path = require('path');
      const Module = require('module');
      const electron = require('electron');
      const basePath = path.join(__dirname, '..', 'app.asar');
      electron.app.getAppPath = () => basePath;
      Module._load(basePath, null, true);
      electron.app.on('ready', () => new (require('path-to-bd').BetterDiscord)());

Injecting through discord_desktop_core

Edit discord_desktop_core/index.js to contain the following.

new (require('path-to-bd').BetterDiscord)();
module.exports = require('./core.asar');

This is usually located at

  • for Windows, %appdata%\discord[channel]\<version>\modules\discord_desktop_core\index.js
  • for macOS, ~/Library/Application Support/discord[channel]/<version>/modules/discord_desktop_core/index.js
  • for Linux, ~/.config/discord[channel]/<version>/modules/discord_desktop_core/index.js