Skip to content

Repository files navigation

Elite Music 🎡

Elite Music is a feature-packed Discord Music Bot built on top of discord.js & using the latest discord-player package.

Loving this open-source project? Leaving a ⭐ on the repository would be much appreciated! ❀️

Features πŸ’‘

  • Wide range of commands.
  • Easy to setup, customise and edit.
  • Slash commands (djs v14).
  • Support for various streaming platforms.
  • Integrated Plex, Jellyfin & Subsonic API support.
  • Docker Support.
  • Full translation support for 30+ languages.
  • Wide range of audio filters.
  • Awesome playback UI.
  • And much more!

Elite Music was originally a part of my verified Discord bot... Elite Bot, but the music section had to be removed due to verification issues. Therefore, in a win situation, I decided to open-source the bot's music code in this repository. And even better, I decided to rewrite the entire bot to improve the code's feature set and overall quality.

Installation πŸ”Œ

Prerequisites πŸ›‚

In order for the bot to function correctly, there are a few prerequisites that you must have on your system.

  • Node.js - The bot requires the Node.js environment running on v20 or newer. It is highly recommended to use the v22 LTS build for long-term stable support. Head over to the NodeJS Download website to download and install an appropriate version.

  • FFmpeg or Avconv - You will require either of these for transcoding. It is recommended to use FFmpeg. By default, the bot comes with the ffmpeg-static binaries as a dependency which allows the bot to work out of the box. Alternatively, you may decide to set your own ffmpeg binaries. In this case, head over to the FFmpeg Download website, select your OS and download the appropriate package. You can then place FFMPEG_PATH as a new option into your .ENV file stating the custom path to your custom FFmpeg binaries.

  • Discord Bot Account - You must register a bot on the Discord Developer site to access a token to run the bot. Head over to the Developer website and click on New Application button. Provide a name and press Create. Next on the left-hand menu, select the Bot section and press Add Bot alongside the confirmation. Finally, press Reset Token and finally copy the token and keep it safe. This is what you will have to place into your .ENV file for the bot to function.

Setup πŸ”§

The first step is to clone the repository or download it manually as a folder to host it directly. The Git option is recommended for more advanced users and for users who already have it installed.

Regular Installation

Basic download

Head over to the download page and download the .zip source code. Next, using a tool such as 7-Zip, extract the files from the .zip folder. You can now move on to the following steps.

Download using Git

An alternative way to download the repository is through the usage of Git. If you do not have Git installed, please use the basic download method. Git users can run the command git clone https://github.com/ThatGuyJacobee/Elite-Bot-Music/tree/main to automatically clone the repository to a new folder.

Continuing the Setup

Now that you have downloaded the repository, you can continue with the following steps.

  1. Open a new command/shell/terminal window within your new folder. You should be able to right-click and open the Windows terminal/command prompt if on Windows.
  2. Run the command npm install to download all of the module dependencies.
  3. Rename the file .env.example to simply .env. Once down, edit the .env file with the configuration options that you would like!
  4. Finally, run your bot using node . within a command/shell/terminal window. The bot should now become online and provide a success message if everything was configured correctly. πŸŽ‰

Tip

To help with development, you can use the npm run dev within your IDE to active nodemon. This will automatically restart the bot each time that a file is saved with new changes, making it easy to work with!

Of course, you need to add your bot to your server now in order to use it. Follow this useful guide from the discord.js Guide which explains how to do this with great detail if you need help understanding how to do this.

YouTube Token Setup (Optional)

Elite Music now has the ability to use a YouTube token from a Google Account to significantly improve the reliability of the YouTube extractor. This is fully optional, as the bot can continue running in scraping mode otherwise.

Typically the YouTube extractor scrapes data anonymously from YouTube thus the chance of your requests being blocked has become increased more recently as YouTube continues to crack down on bot requests. With a token, the bot can instead access the YouTube account and access music data whilst logged in, which significantly reduces the chances of being blocked by YouTube.

Tip

This is especially recommended if you are facing YouTube search and playback issues frequently with your bot, due to YouTube blocking your anonymous requests.

  1. Run the command npx --no discord-player-youtubei in your prompt.
  2. Follow the instructions that are printed to your console. Mainly, access the provided link, input the code and login with a Google Account.

Important

It is highly recommended to use a random throwaway/alternative Google Account for this. Using your main account might put you at risk of a suspension or ban, better to be safe than sorry!

  1. Once you completed the Google Account flow, a cookie string will be printed to your console.
  2. Copy the full string from start to finish. Paste this into the YT_CREDENTIALS field within your .env file.
  3. Save the file and restart the bot.

Installation via Docker

Elite Music now has Docker image and Docker Compose support, allowing you to simply install and use the bot through Docker.

You can access the Docker Image via Docker Hub which provides the image and the instructions within the description. The instructions to either install via Docker Run or Docker Compose are also provided below. Once you have installed and configured your bot, you will need to add your bot to your server now in order to use it. Follow this useful guide from the discord.js Guide which explains how to do this with great detail if you need help understanding how to do this.

Docker Run Command

You should use the following command to download the image and run it:

docker run -d \
--name=elite-music \
--env-file /path/to/.env \
--restart unless-stopped \
thatguyjacobee/elitemusic:latest

Note: The --env-file path is relative to the directory you are running your docker run command from.

See the .env.sample file on the GitHub repository to view and copy over all of the environmental options into your target .env file for the bot.

Docker Compose

Use the following for your docker-compose.yml file:

version: "3"
services:
    elitemusic:
        container_name: "elite-music"
        image: "thatguyjacobee/elitemusic:latest"
        env_file:
            - /path/to/.env
        restart: unless-stopped

Once again, see the .env.sample file on the GitHub repository to view and copy over all of the environmental options into your target .env file for the bot.

Optional Features βœ…

You may decide to want to enable additional optional features for your bot. Follow the appropriate sub-heading to learn how to set up and enable the selected feature!

If you are missing the relevant option in your environmental (.env) file, make sure to check the latest .env.sample file to ensure you are on the latest version.

Once you have followed the appropriate steps for the optional feature that you want to enable, you should start the bot and ensure that the configuration option returns as true when the configuration loads. If the feature still shows as disabled, this suggests that you have a configuration error. Follow the error logs that are provided in your console to resolve this. If you are still having trouble with your issue, feel free to create an issue on the repository or join the Support Discord server.

Playback source order

The environment variable PLAYBACK_SOURCE_ORDER allows you to control which audio sources are used by the /play and /playnext commands. After extracting the requested song information, each configured source is checked from left to right until a confident match is found. /search uses the same order, but lists confident matches from every configured source instead of stopping at the first hit.

PLAYBACK_SOURCE_ORDER='plex,subsonic,jellyfin,default'

The available sources are plex, subsonic, jellyfin, and default. The default source uses the normal discord-player playback methods which is mainly YouTube or direct URL streaming where applicable.

You can remove or reorder these sources depending on your setup. For example, use PLAYBACK_SOURCE_ORDER='subsonic' to only play matched Subsonic tracks, or PLAYBACK_SOURCE_ORDER='default' to retain the original playback behaviour. Any optional addon that is not enabled will be skipped automatically.

If the option is missing, empty, or contains no valid sources, it defaults to default.

Plex Media Server playback

The Plex Media Server optional feature allows you to stream music directly from your Plex library through the /plex command or as an enabled /play source. In order to enable the Plex feature, you must go into your .env file and set up the configuration for your server.

  1. Firstly, set ENABLE_PLEX to true.
  2. Next, provide the base URL of your Plex Media Server in PLEX_SERVER. The default port that Plex Media Server runs on is 32400 (e.g. http://[your_ipaddress]:32400). You can verify that the URL is correct by opening it in a web browser; you should see your server's login page load successfully. The bot must be able to reach this address from the machine or container it runs on.
  3. Set PLEX_AUTHTOKEN to your Plex authentication token. You can obtain this by browsing the XML file for a library item. Please follow the official Plex Support article for step-by-step instructions. Once you have your token, place it into your .env file.

Once configured and restarted, the bot will validate the connection on startup and return a configuration loaded message. As long as everything is valid and the feature remains active, you will be able to utilise all of the /plex commands.

Subsonic API playback

The Subsonic API optional feature allows you to stream music directly from your Subsonic-compatible media server through the /subsonic command or as an enabled /play source. This works with any server that implements the Subsonic REST API, such as Navidrome, Airsonic-Advanced, Gonic or others. In order to enable the Subsonic feature, you must go into your .env file and set up the configuration for your server.

  1. Firstly, set ENABLE_SUBSONIC to true.
  2. Next, provide the base URL of your Subsonic server in SUBSONIC_SERVER. The default port for many Subsonic-compatible servers is 4533 (e.g. http://[your_ipaddress]:4533). You can verify that the URL is correct by opening it in a web browser; you should see your server's login or home page load successfully. The bot must be able to reach this address from the machine or container it runs on.
  3. Set SUBSONIC_USER and SUBSONIC_PASS to a valid account on your server. Elite Music authenticates using the standard Subsonic token scheme, so use the same username and password you would use in a Subsonic client app.
  4. Optionally, set SUBSONIC_APP_NAME to identify this bot to your server (defaults to Elite-Music-Bot if left unchanged).

Once configured and restarted, the bot will validate the connection on startup and return a configuration loaded message. As long as everything is valid and the feature remains active, you will be able to utilise all of the /subsonic commands.

Jellyfin Media Server playback

The Jellyfin Media Server optional feature allows you to stream music directly from your Jellyfin library through the /jellyfin command or as an enabled /play source. In order to enable the Jellyfin feature, you must go into your .env file and set up the configuration for your server.

  1. Firstly, set ENABLE_JELLYFIN to true.
  2. Next, provide the base URL of your Jellyfin Media Server in JELLYFIN_SERVER. The default port that Jellyfin runs on is 8096 (e.g. http://[your_ipaddress]:8096). You can verify that the URL is correct by opening it in a web browser; you should see your server's login page load successfully. The bot must be able to reach this address from the machine or container it runs on.
  3. Set JELLYFIN_API_KEY to a valid API key for your server. You can create one from the Jellyfin admin dashboard under Dashboard -> API Keys. Once you have your key, place it into your .env file.
  4. Set JELLYFIN_USER to a valid username on your server. Elite Music uses this account when searching your library and building stream URLs.

Once configured and restarted, the bot will validate the connection on startup and return a configuration loaded message. As long as everything is valid and the feature remains active, you will be able to utilise all of the /jellyfin commands.

DJ Mode

Elite Music comes with a DJ Mode optional feature, which locks down the use of commands and interactions to members who have the specified DJ Role.

  1. Firstly, set ENABLE_DJMODE to true.
  2. Now create a role on your server which you wish to be used as the DJ Role. Copy the ID of the role and place it into the DJ_ROLE field.

Soft Transitions

Soft Transitions fades tracks out and in during playback (skip, natural song changes, etc.) instead of hard cuts. Audio never overlaps - it's a sequential fade, not a true crossfade (due to limitations).

  1. Firstly, set ENABLE_SOFT_TRANSITIONS to true.
  2. Optionally, set SOFT_TRANSITION_MS to the duration of each fade-out or fade-in in milliseconds (200-5000, default 2000). This is the length of a single fade direction, not the combined transition.

Translations & Localisation

Elite Music includes built-in localisation. Translation strings are stored as JSON files in the locales/ folder, with en-GB.json acting as the default and main source for all keys. Locale files are included for all Discord client languages.

You can configure this in your .env file using PRIMARY_LOCALE (defaults to en-GB) and LOCALE_MODE (defaults to user). Set LOCALE_MODE to user if you want the bot to localise based on each user's Discord client language where possible, falling back to your primary locale when needed. Set it to global if you want the bot to always use your primary locale instead.

Contributions 🀝

Contributions are always welcome, whether that's new features, translations, or everything in between. These will be reviewed when possible but may not always be merged if outside of the scope of the project or other reasons.

Support πŸ†˜

Need help setting up the bot or experiencing some trouble? Feel free to head over to the Support Discord server and let me know!

Found a bug or issue with the latest build? Feel free to open an issue on this repository! I will respond as soon as possible.

Elite Bot - Verified Multi-Purpose Bot πŸ’ͺ

Looking for a multi-purpose Discord Bot for your server? Look no further, check out Elite Bot to fulfil all of your server needs including moderation, logging, external server status and much more!

Check the bot out via the dedicated documentation website or top.gg today! πŸš€

License πŸ“„

GNU Affero General Public License v3.0 Β© ThatGuyJacobee

About

Elite Music is an open-source, feature-packed Discord music bot running on discord.js and discord-player. The bot is complete with large selection of commands, effects, optional features, autoplay, customisability and much more! πŸš€πŸ’ͺ

Topics

Resources

Stars

41 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages