How to Setup a Discord Musicbot on Ubuntu or Debian using Docker-Compose
Server Requirements
We’ll be using Redbot (a multi purpose open-source discord bot) for this guide, server requirements aren’t offically posted so I recommend the following:
vCPU: 1+ Core
RAM: 1GB+ (512mb swap or more)
Disk Space: 10GB+
Step 1 – Install docker & docker-compose
Firstly update your system, on Debian you can use the below command.
apt-get update && apt upgrade
Then install docker if it’s not already installed, I use typically use the docker install script found at github.com/docker/docker-install
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
After the script is complete, install docker-compose.
apt install docker-compose
Step 2 – Creating the redbot directory & docker-compose file
Create a new directory in the home/root folder of your VPS, then cd
into the directory & create the docker-compose.yml file.
mkdir redbot
cd redbot
mkdir data
nano docker-compose.yml
Paste the following into the docker-compose file
version: "3.3"
services:
redbot:
container_name: redbot
image: phasecorex/red-discordbot
restart: unless-stopped
volumes:
- /root/redbot:/data
environment:
- TOKEN=xxx
- PREFIX=xxx
- OWNER=xxx
- TZ=Australia/Brisbane
- PUID=1000
Edit the environment variables to suite, namely “Token” “Prefix” “Owner” & “TZ”. You’ll also need a Discord Bot token to enter in here, if you don’t already have one, you can follow this guide found at writebots.com
Step 3 – Starting the bot
To start the bot & run it for everyday use, simply cd into the redbot directory & run docker-compose up with the detached flag.
docker-compose up -d
Step 4 – Getting the initial invite link
To get the initial link to invite the bot into your first Discord server you’ll need to either run the docker-compose file without the -d flag or use the Discord OAUTH Link generator.
For this guide, we’ll run the bot without detaching the container to get the invite link then we’ll restart the bot & detach the container so it runs in the background.
If the bot is running from the previous step:
docker-compose down
then run:
docker-compose up
The container will then start up & start the python environment, once finished it will output something similar to this:
Setting bot owner...
redbot | Setting bot token...
redbot | Setting bot prefix(es)...
redbot | Starting Red-DiscordBot!
redbot | [2023-01-16 21:24:21] [INFO] red: Loading packages...
redbot | [2023-01-16 21:24:23] [INFO] red: Loaded packages: audio, downloader, botstatus, heartbeat, pingtime, anotherpingcog
redbot | [2023-01-16 21:24:24] [INFO] red: Connected to Discord. Getting ready...
redbot |
redbot | ______ _ ______ _ _ ______ _
redbot | | ___ \ | | | _ (_) | | | ___ \ | |
redbot | | |_/ /___ __| | ______ | | | |_ ___ ___ ___ _ __ __| | | |_/ / ___ | |_
redbot | | // _ \/ _` | |______| | | | | / __|/ __/ _ \| '__/ _` | | ___ \/ _ \| __|
redbot | | |\ \ __/ (_| | | |/ /| \__ \ (_| (_) | | | (_| | | |_/ / (_) | |_
redbot | \_| \_\___|\__,_| |___/ |_|___/\___\___/|_| \__,_| \____/ \___/ \__|
redbot |
redbot | โญโโโโโโโโโโโ Lexbot โโโโโโโโโโโโโฎ โญโโโโโโโโโโโโโโโโโโโโโโฎ
redbot | โ Prefixes โ - โ โ Shards โ 1 โ
redbot | โ Language โ en-US โ โ Servers โ 4 โ
redbot | โ Red version โ 3.4.18 โ โ Unique Users โ 93 โ
redbot | โ Discord.py version โ 1.7.3 โ โฐโโโโโโโโโโโโโโโโโโโโโโฏ
redbot | โ Storage type โ JSON โ
redbot | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
redbot | Loaded 8 cogs with 74 commands
redbot |
redbot | Invite URL:
redbot | https://discord.com/oauth2/authorize?client_id=xxxxxxxxxxxxxx&scope=bot
redbot | [2023-01-16 21:24:28] [INFO] red.Audio.manager: Internal Lavalink server started. PID: 118
You’ll notice the Invite URL posted in the logs, copy & paste this into a browser to check permissions & invite the bot to your server.
redbot | Invite URL:
redbot | https://discord.com/oauth2/authorize?client_id=xxxxxxxxxxxxxx&scope=bot
Once you can see the bot online on your Discord server, bring the container offline & restart it with the detached flag to enable it to run in the background & automatically start up upon system boot.
CTRL+C
docker-compose up -d
You should now be all finished, you can save the invite link so that you can distribute it or you can run the [prefix]invite
command on Discord to have your bot message you another link.
Step 5 – Enabling the audio module
You can enable to audio module by entering the [prefix] load audio
command into your discord server.
[prefix]load audio
You can see additional help for any command in this guide by using [prefix]help
with the command name, like [prefix]help playlist append.
Note
All commands should be used in a Discord server, and not in Direct Messages as audio commands are not available there. All Audio Commands
Further documentation
If you want to find more commands or uses for redbot, you can find plenty of more information on the offical redbot documentation website