A self-hosted Discord bot that plays music from YouTube in voice channels.
Important: This bot is for personal/private use only. See Disclaimer at the bottom.
Before you start, you need:
-
Docker Desktop (or Docker + Docker Compose on Linux)
- Windows/Mac: Download from docker.com/products/docker-desktop
- Linux: Install Docker Engine and Docker Compose
-
A Discord Bot Token
- You'll create this in the setup steps below
-
A VPN subscription with WireGuard support
- Recommended: Mullvad VPN (~$5/month)
- Why? YouTube blocks datacenter IPs. The VPN makes it work.
git clone https://github.com/evman/mybot.git
cd mybotOr download as ZIP from GitHub and extract it.
- Go to discord.com/developers/applications
- Click "New Application"
- Give it a name (e.g., "Music Bot") and click Create
- Go to the "Bot" tab on the left
- Click "Reset Token" and copy the token - save this somewhere safe!
- Scroll down and enable these settings:
- Presence Intent - OFF (not needed)
- Server Members Intent - OFF (not needed)
- Message Content Intent - OFF (not needed)
Copy these two things:
- Token - from the Bot tab (looks like
MTQ1ODA2MzkyNTQ3MDk1NzY3Nw.GRDYt9.xxxxx) - Application ID - from the General Information tab (a number like
1458063925470957677)
For Mullvad (recommended):
- Go to mullvad.net and create an account
- Go to mullvad.net/en/account/wireguard-config
- Generate a WireGuard configuration
- Download the config file and open it in a text editor
- You need these two values:
- PrivateKey - looks like
AL/uVnzW+omjg/tBRMp42SRjvAHiagEMcFimOMIeeV4= - Address - looks like
10.64.216.95/32
- PrivateKey - looks like
-
Copy the example config:
cp .env.example .env
-
Open
.envin a text editor (Notepad, VS Code, nano, etc.) -
Replace the placeholder values with your actual values:
# Paste your Discord bot token here DISCORD_TOKEN=MTQ1ODA2MzkyNTQ3MDk1NzY3Nw.GRDYt9.xxxxx # Paste your Discord Application ID here DISCORD_CLIENT_ID=1458063925470957677 # Leave these as-is LAVALINK_HOST=localhost LAVALINK_PORT=2333 LAVALINK_PASSWORD=youshallnotpass # Paste your WireGuard PrivateKey here WIREGUARD_PRIVATE_KEY=AL/uVnzW+omjg/tBRMp42SRjvAHiagEMcFimOMIeeV4= # Paste your WireGuard Address here WIREGUARD_ADDRESSES=10.64.216.95/32
-
Save the file
Open a terminal in the bot folder and run:
docker compose up -dFirst time will take a few minutes - it's downloading everything it needs.
To check if it's running:
docker compose psYou should see four containers all showing "Up" or "healthy":
gluetun- the VPNlavalink- the audio serverlavalink-updater- auto-updates the YouTube pluginmusicbot- the bot itself
- Go to discord.com/developers/applications
- Click on your application
- Go to "OAuth2" > "URL Generator"
- Under Scopes, check:
botapplications.commands
- Under Bot Permissions, check:
ConnectSpeak
- Copy the generated URL at the bottom
- Open the URL in your browser and select your server
- Join a voice channel in your Discord server
- Type
/playfollowed by a song name or YouTube URL - The bot will join and start playing!
| Command | What it does |
|---|---|
/play <song> |
Play a song (YouTube URL or search) |
/skip |
Skip to the next song |
/stop |
Stop playing and leave the channel |
/queue |
Show what's coming up next |
/pause |
Pause the music |
/resume |
Unpause the music |
/volume <1-100> |
Change the volume |
The audio server isn't ready yet. Wait 30 seconds and try again.
Check if it's running:
docker compose psIf lavalink shows "unhealthy", check the logs:
docker compose logs lavalinkThe VPN might not be connected. Check gluetun:
docker compose logs gluetunLook for a line that says "Healthy!" or shows an IP address.
If you see errors about authentication, double-check your WireGuard credentials in .env.
- Make sure the bot is online in Discord (should show in member list)
- Try kicking the bot and re-inviting it
- Check the bot logs:
docker compose logs bot
The VPN connection might be unstable. Try changing the server location in docker-compose.yml:
- SERVER_CITIES=Zurich # Change this to another cityThen restart:
docker compose down
docker compose up -d# Start the bot
docker compose up -d
# Stop the bot
docker compose down
# Restart everything
docker compose restart
# See what's running
docker compose ps
# View logs (all)
docker compose logs
# View bot logs only
docker compose logs bot
# View logs in real-time (press Ctrl+C to stop)
docker compose logs -f
# Rebuild after making code changes
docker compose up -d --buildgit pull
docker compose up -d --buildmybot/
├── .env # YOUR SECRETS - never share this!
├── .env.example # Template for .env
├── docker-compose.yml # Docker configuration
├── Dockerfile # How to build the bot
├── package.json # Node.js dependencies
├── lavalink/
│ └── application.yml # Audio server config
├── updater/ # Auto-update container
│ ├── Dockerfile
│ └── check-update.sh
└── src/ # Bot source code
├── index.ts
├── config.ts
├── commands/
└── music/
YouTube frequently changes their systems, which can break playback. This bot includes an automatic updater that:
- Checks for new youtube-plugin versions every hour
- Automatically updates the config when a new version is found
- Restarts Lavalink to apply the update (causes ~10 second interruption)
Check updater logs:
docker compose logs updaterDisable auto-updates (if you want manual control):
Remove or comment out the updater service in docker-compose.yml.
The bot uses gluetun which supports many VPN providers.
Edit docker-compose.yml and change the gluetun environment section. See the gluetun wiki for your provider's settings.
This bot is for personal, private use only.
Streaming audio from YouTube may violate their Terms of Service. By using this software, you accept full responsibility for how you use it. The developers are not responsible for any misuse or violations of third-party terms of service.
This project is not affiliated with Discord, YouTube, Google, or any VPN provider.
MIT - Do whatever you want with it.