How to Setup a Discord Musicbot on Ubuntu 20.04 using Docker-Compose
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+
From the offical Redbot documents: Docker support found in GitHub is also a work in progress and not ready for daily use. Workarounds for getting Red running on those platforms are imperfect due to Red’s nature. You will not be able to receive support if an issue occurs when hosting on any of these platforms.
Step 1 - Install docker & docker-compose
Firstly update your system, on Debian you can use the below command.
sudo apt-get update && sudo apt upgrade
curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh
sudo 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
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:
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
redbot | Invite URL: redbot | https://discord.com/oauth2/authorize?client_id=xxxxxxxxxxxxxx&scope=bot
CTRL+C docker-compose up -d
[prefix]invitecommand 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]helpwith the command name, like
[prefix]help playlist append.
All commands should be used in a Discord server, and not in Direct Messages as audio commands are not available there.
All Audio Commands
[prefix]play - Play a single song or a playlist URL or use this command with words to search for a song.
[prefix]search - Search for a track on YouTube. Searching on Soundcloud can be done with [p]search sc and the keywords to search for.
[prefix]stop - Stops playback and clears the queue.
[prefix]pause - This is a toggle. Use [p]pause again to resume the music.
[prefix]prev - Stops playback of the current song and returns to the start of the previous song played.
[prefix]skip - Skip to the next song in the queue, if there is one.
[prefix]seek - Seek ahead to a specific track time, or seek ahead by seconds.
[prefix]now - Show what song is currently playing.
[prefix]volume - Set the volume from 0% to 150%. 100% is the default. Discord server owners can set a limit to the volume with [p]audioset maxvolume.
If you want to find more commands or uses for redbot, you can find plenty of more information on the offical redbot documentation website