- Go 96%
- Nix 4%
| cmd/thischord | ||
| internal | ||
| samples | ||
| .envrc | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| README.md | ||
,--------.,--. ,--. ,-----.,--. ,--. '--. .--'| ,---. `--' ,---. ' .--./| ,---. ,---. ,--.--. ,-| | | | | .-. |,--.( .-' | | | .-. || .-. || .--'' .-. | | | | | | || |.-' `)' '--'\| | | |' '-' '| | \ `-' | `--' `--' `--'`--'`----' `-----'`--' `--' `---' `--' `---'
A Discord music bot hoping to act as a comparable replacement for jMusicBot, built with Go.
This is meant to be self-hosted and can support 1 guild per instance.
Summary
- Prerequisites
- Features
- Missing Features
- Planned Additions
- Making a Discord Application
- Getting Started with Lavalink
- Getting Started with ThisChord
- Starting the Music Bot
Prerequisites
- An application created in the Discord Developer Portal
- Go 1.25.1+
- Java 17 or higher
- Lavalink
- yt-dlp
- ffmpeg
Features
- Search for music on YouTube
- Play music from YouTube by search query or URI
- Add additional songs into a queue
- Skip songs
- Shuffle the queue
- Clear the queue
- See what's playing, and the position of the seeker
- Stop & pause playback
Missing Features
- Ability to repeat:
- tracks
- queues
- Loading playlists from YouTube
- Additional music sources:
- SoundCloud
- Bandcamp
- Vimeo
- Premium services like:
- Spotify
- Apple Music
- Deezer
Planned Additions
- YAML or JSON config instead of using .env file
- Ability to run w/ Docker
- CI/CD integration
- Return custom embeds instead of plain old text responses:
- Now Playing:
- media control buttons
- seeker progression
- added by
- art (cover/album art)
- Searching
- Skipping
- etc.
- Now Playing:
Making a Discord Application
First, we want to navigate to the Discord Developer Portal and click New Application in the top right, then proceed with editing the following sections.
General Information
We don't really need to change anything here unless you decide to change the name of the application.
Installation
Check Guild Install only, and ensure the scope has applications.commands and bot in it, then add the following permissions:
- Add Reactions
- Connect
- Embed Links
- Priority Speaker
- Read Message History
- Request To Speak
- Send Messages
- Send Messages in Threads
- Speak
- Use Slash Commands
- Use Voice Activity
- View Channels
Tip
You'll use the URL found under
Install Linkto invite the bot to your server.
Bot
Here, give your bot an optional profile picture, and a username. Ensure the following are enabled:
- Public Bot
- Presence Intent
- Server Members Intent
Tip
This is where you'll also get your bot token, under the
Tokensection of this page.
Getting Started with Lavalink
Installing Lavalink
Please follow the official Lavalink documentation here
Setting up Lavalink as a Service
Please follow the official Lavalink documentation on creating a systemd service here
Configuring Lavalink
Lavalink needs a bit of additional configuration before we can use it with YouTube. You'll want to create a file called application.yml in the directory with Lavalink.jar - I recommend copying the sample and changing the password to your liking.
Getting Started with ThisChord
Installing ThisChord
Important
Please ensure you have Go 1.25.1+ on your machine; installation instructions can be found here
To install ThisChord, run the following in your terminal, which will output the binary file to $GOBIN
$ go install codeberg.org/eleina/thischord/cmd/thischord@latest
Tip
Either export
GOBINin your shell profile, or rungo env -w GOBIN=/path/to/some/bin
Setting up ThisChord as a Service
Create a file in /etc/systemd/system named thischord.service with the following:
[Unit]
Description=ThisChord Music Bot
After=lavalink.service syslog.target network.target
Requires=lavalink.service
[Service]
User=BOT_USER # replace this with the user you run the bot as, i.e. bot
Group=BOT_GROUP # replace this with the user's group you run the bot as, i.e., bot
WorkingDirectory=/path/to/bin/with/bot # i.e. /home/bot
ExecStart=/path/to/bin/with/bot/thischord # i.e /home/bot/thischord
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Configuring ThisChord
Navigate to $GOBIN, or wherever you placed the thischord binary, and create a .env file. I recommend copying the sample and filling it in with details specific to your instance and Discord guild.
Starting the Music Bot
Important
Please ensure you have yt-dlp and ffmpeg installed before starting the bot.
You'll want to reload the systemctl daemon:
$ sudo systemctl daemon-reload
and then enable & start both the Lavalink and ThisChord services:
$ sudo systemctl enable --now lavalink.service
$ sudo systemctl enable --now thischord.service
Lastly, let's make sure things are running smoothly. Run the following commands to ensure everything started properly:
$ systemctl status lavalink.service
$ systemctl status thischord.service
That should be all! You now have a music bot for your server! Make sure to periodically check this repo for updates!