Skip to content
intrnl edited this page Aug 22, 2018 · 34 revisions

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

Table of Contents

Requirements

  • Node 6 or later

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 ci and npm run release in the root folder
    This will delete the release directory, including any user data, rebuilds it and copy the node-sass bindings

  3. Download the emote data and move it to release/data
    You can skip this step if you don't need to see the emotes

  4. Edit discord_desktop_core/index.js to contain the following

    new (require('path-to-bd/release').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

To rebuild the release, follow step 2 and 3 again.

Development

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

  1. Clone the repository

  2. Run npm ci and npm run build in the root folder

  3. Build the node-sass bindings by yourself using npm run build_node-sass, or copy the prebuilt bindings from other/node_sass_bindings

    :: Windows
    copy "other\node_sass_bindings\win32-ia32-53" "node_modules\node-sass\vendor\win32-ia32-53"
    # macOS
    cp -R other/node_sass_bindings/darwin-x64-53 node_modules/node-sass/vendor/darwin-x64-53
    
    # Linux
    cp -R other/node_sass_bindings/linux-x64-53 node_modules/node-sass/vendor/linux-x64-53
  4. Download the emote data and move it to tests/data
    You can skip this step if you don't need to see the emotes

  5. 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 local

    Injecting through local

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

      This is usually located at

      • for Windows, %localappdata%\Discord[channel]\app-<version>\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');
        const pkg = require(path.join(basePath, 'package.json'));
        electron.app.getAppPath = () => basePath;
        Module._load(path.join(basePath, pkg.main), null, true);
        electron.app.on('ready', () => {new (require('path-to-bd/core').BetterDiscord)();});

    Injecting through discord_desktop_core

    Edit discord_desktop_core/index.js to contain the following

    new (require('path-to-bd/core').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

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, ruun npm run watch_csseditor

Core rebuilds requires a full Discord restart, while client and CSS Editor you only need to reload Discord by pressing Ctrl/Cmd + R

Notes

While building, it might throw an error saying that node-sass is missing the necessary bindings, in that case, you need to download the following files.

  • for Windows,

  • for macOS,

    • for Node 10, x64
    • for Node 9, x64
    • for Node 8, x64
  • for Linux,

Once downloaded, make a folder in node_modules/node-sass/vendor with a name based on the binding file, for example win32-x64-64 from win32-x64-64_binding.node, then move the binding file over and rename it to binding.node

Clone this wiki locally