This is a music bot for discord made using golang. Priorities are high-performance and low footprint.
- Play: Adds a song to the queue via URL or search query
- Ping: Tests the messagehandler, most likely will be removed in the future
- Queue: Outputs the current queue
- Skip: Skips the current song, and plays the next one
- Loop: Switches between three modes: off, current song, current queue
- Join: Joins the voice channel that the user is in
- Volume: Outputs the volume if there are 0 arguments, or sets the volume if there are arguments.
- Pause: Pauses the current song
- Resume: Resumes the current song
- Playsample: This tests the play command, most likely will be removed in the future
- Setname: Sets the name of the bot
- Setavatar: Sets the avatar of the bot
- Shuffle: Shuffles between songs, when loop is off
- Clear: Clears the current queue
This bot uses I/O instead of Memory to store files, in-order to save memory and because reading a music file isn't that I/O-intensive.
The process of playing a song goes as followed:
First, it downloads the file of the video to song.mp3
.
Second, it uses ffmpeg to standardize any audio file to later convert to discord's own audio encoding.
Third, it converts the ffmpeg file called song.dca
, to discord-specific audio encoding and sends it at the same time.
After a song is done playing, the files are then emptied. The reason we don't delete them is we would have to allocate new file pointers.
- ffmpeg(runtime)
- golang(build time)
Current this music bot supports only linux, if you are running windows or mac os it won't work for you. This is due to using the gopus.
go get -u # Get all the golang dependencies
go build # Build the binary
You can download one of the pre-built binaries, and do:
chmod +x music
./music
Configuration is done through the config file, possible file extensions are: json
, toml
, yaml
, hcl
, envfile
.
Current values to set are: