betterdiscord-theme-template

BetterDiscord Theme Template

A customizable BetterDiscord theme template built with SCSS, featuring automated build processes and local development workflow.


πŸ“‘ Table of Contents


πŸš€ Quick Navigation

I want to… Go to
Get started quickly Quick Start
Develop locally Development Workflow
Customize colors and styles Customization Guide
Deploy my theme Deployment
Fix issues Troubleshooting
Learn all commands Available Scripts
Understand the file structure Project Structure

Features

Prerequisites

Quick Start

1. Clone and Install

git clone https://github.com/yourusername/your-theme.git
cd your-theme
npm install

2. Configure Environment

Copy the example environment file and customize it:

cp .env.example .env

Edit .env to configure your theme:

# Whether to allow automatic copying of the theme to BetterDiscord folder
ALLOW_THEME_COPY=false

# File names used in the build process
USER_FILE=example.theme.css
LOCAL_TEST_FILE=example.local.theme.css
COMPILED_FILE=compiled-theme.css
COMPILED_MIN_FILE=compiled-theme.min.css

Important: Set ALLOW_THEME_COPY=true only if you want automatic copying to your BetterDiscord themes folder during development.

3. Customize Your Theme

Edit example.theme.css to set your theme metadata and variables:

/**
 * @name Your Theme Name
 * @description A customizable BetterDiscord theme
 * @version 0.0.1
 * @author Your Name
 */

Customize the CSS variables in the :root section to change colors, fonts, sizes, and effects.

4. Start Development

npm run watch:local

This will:

Available Scripts

Development

Building

Code Quality

Project Structure

betterdiscord-theme-template/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ modules/                  # SCSS modules for different Discord components
β”‚   β”‚   β”œβ”€β”€ _variables.scss       # Theme variables
β”‚   β”‚   β”œβ”€β”€ _colors.scss          # Color definitions
β”‚   β”‚   β”œβ”€β”€ _fonts.scss           # Font imports and definitions
β”‚   β”‚   β”œβ”€β”€ _backgrounds.scss     # Background styling
β”‚   β”‚   β”œβ”€β”€ _discord-*.scss       # Discord component styles
β”‚   β”‚   β”œβ”€β”€ _betterdiscord.scss   # BetterDiscord specific styles
β”‚   β”‚   └── _plugins.scss         # Plugin compatibility styles
β”‚   β”œβ”€β”€ utils/                    # Build utilities
β”‚   β”‚   └── buildLocal.js         # Local theme builder
β”‚   β”œβ”€β”€ config.js                 # Environment configuration
β”‚   β”œβ”€β”€ local-build.js            # Local build script
β”‚   β”œβ”€β”€ local-watch.js            # Local watch script
β”‚   └── main.scss                 # Main SCSS entry point
β”œβ”€β”€ dist/                         # Compiled output files
β”‚   β”œβ”€β”€ compiled-theme.css        # Expanded compiled CSS
β”‚   β”œβ”€β”€ compiled-theme.min.css    # Minified compiled CSS
β”‚   └── example.local.theme.css   # Local test theme (inline CSS)
β”œβ”€β”€ assets/                       # Theme assets (fonts, images)
β”œβ”€β”€ example.theme.css             # User-facing theme file (template)
β”œβ”€β”€ .env.example                  # Example environment configuration
β”œβ”€β”€ .prettierrc.js                # Prettier configuration
β”œβ”€β”€ eslint.config.js              # ESLint configuration
└── package.json                  # Project dependencies and scripts

Development Workflow

Standard Workflow (with hosting)

  1. Edit SCSS files in src/modules/
  2. Run npm run build to compile CSS
  3. Host dist/compiled-theme.css on GitHub Pages or a CDN
  4. Update the @import URL in example.theme.css
  5. Users install example.theme.css in BetterDiscord

Local Testing Workflow (no hosting needed)

  1. Edit SCSS files in src/modules/
  2. Run npm run watch:local
  3. The script automatically:
    • Compiles SCSS to CSS
    • Combines your theme template with compiled CSS
    • Creates a local test file with embedded CSS
    • Optionally copies to BetterDiscord themes folder
  4. Enable the theme in Discord to see changes immediately

Customization Guide

For Theme Developers

Modifying Colors

Edit src/modules/_colors.scss to change the color scheme:

:root {
  --primary-color: #5865f2;
  --secondary-color: #3ba55d;
  // ... more colors
}

Adding Custom Fonts

  1. Place font files in assets/fonts/
  2. Import them in src/modules/_fonts.scss
  3. Reference them in your theme variables

Modifying Component Styles

Each Discord component has its own SCSS module in src/modules/:

Edit the relevant file to customize specific components.

For End Users (Customizing Without Editing Theme File)

Users can customize the theme without editing the .theme.css file directly by using BetterDiscord’s Custom CSS feature. This method is recommended because:

How to use Custom CSS:

  1. Open Discord Settings β†’ BetterDiscord β†’ Custom CSS
  2. Copy and paste the variables you want to customize from the theme file
  3. Modify the values to your preference
  4. Save and enjoy your customized theme!

Example Custom CSS:

/* Custom color scheme */
:root {
  --primary-color: #ff6b6b; /* Change accent color to red */
  --background-primary: #1a1a1a; /* Darker background */
  --server-size: 56px; /* Larger server icons */
}

/* Optional: Enable custom background */
:root {
  --use-custom-background: 1;
  --custom-background: url("https://i.imgur.com/your-image.jpg");
  --background-blur: 8px;
  --background-opacity: 0.9;
}

Tips:

Deployment

GitHub Pages provides free, reliable hosting for your theme’s CSS files.

Setup GitHub Pages

  1. Enable GitHub Pages:
    • Go to your repository settings
    • Navigate to Pages (under β€œCode and automation”)
    • Under Source, select Deploy from a branch
    • Select main branch and / (root) folder
    • Click Save
  2. Build your theme:
    npm run build
    
  3. Commit and push the dist folder:
    git add dist/
    git commit -m "Build theme for deployment"
    git push origin main
    
  4. Update your theme file:

    Edit example.theme.css and update the @import URL to your GitHub Pages URL:

    @import url("https://yourusername.github.io/your-theme-repo/dist/compiled-theme.css");
    

    Your GitHub Pages URL format is: https://[username].github.io/[repository-name]/dist/compiled-theme.css

  5. Verify deployment:
    • Wait 1-2 minutes for GitHub Pages to deploy
    • Visit your CSS file URL in a browser to confirm it’s accessible
    • The CSS code should display in your browser

Alternative: Use gh-pages branch

For a cleaner setup that keeps build files separate from your source code:

  1. Install gh-pages utility:
    npm install --save-dev gh-pages
    
  2. Add deploy script to package.json:
    {
      "scripts": {
        "deploy": "npm run build && gh-pages -d dist"
      }
    }
    
  3. Deploy to GitHub Pages:
    npm run deploy
    
  4. Configure GitHub Pages:
    • Go to repository settings β†’ Pages
    • Select gh-pages branch
    • Your theme will be at: https://yourusername.github.io/your-theme-repo/compiled-theme.css

Option 2: CDN Hosting

Alternative hosting options:

jsDelivr (Free CDN for GitHub)

Automatically serves files from your GitHub repository:

@import url("https://cdn.jsdelivr.net/gh/yourusername/your-theme-repo@main/dist/compiled-theme.css");

Benefits:

Other CDN Options

Option 3: Self-Hosted

Host on your own web server:

  1. Build the theme: npm run build
  2. Upload dist/compiled-theme.css to your web server
  3. Update the @import URL to your server’s URL
  4. Ensure CORS headers are set correctly:
    Access-Control-Allow-Origin: *
    

Distribution

Once hosted, distribute your theme:

  1. Create a release:
    • Tag your version: git tag v1.0.0
    • Push tags: git push --tags
    • Create a GitHub release with the theme file attached
  2. Share the theme file:
    • Users download example.theme.css (or your renamed version)
    • Users place it in their BetterDiscord themes folder
    • The theme automatically loads CSS from your hosted URL
  3. Update your theme:
    • Edit SCSS files
    • Run npm run build
    • Commit and push changes
    • Users get updates automatically (no need to reinstall)

Troubleshooting

Theme not appearing in Discord

Changes not showing

Build errors

CSS not loading from hosted URL

GitHub Pages not updating

Code Quality

This project uses:

Pre-commit hooks will automatically:

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Run npm run lint:fix and npm run format:fix
  5. Commit your changes: git commit -m 'Add feature'
  6. Push to the branch: git push origin feature-name
  7. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Support


Note: This is a template. Remember to customize: