Melodix Player is my pet project that plays audio from YouTube and audio streaming links to Discord voice channels.
- 🎶 Single track added by song name or YouTube link.
- 🎶 Multiple tracks added via multiple YouTube links (space separated).
- 🎶 Tracks from public user playlists.
- 🎶 Tracks from "MIX" playlists.
- 📻 Streaming links (e.g., radio stations).
- 🌐 Operation across multiple Discord servers (guild management).
- 📜 Access to history of previously played tracks with sorting options.
- 💾 Downloading tracks from YouTube as mp3 files for caching.
- 🎼 Sideloading audio mp3 files.
- 🎬 Sideloading video files with audio extraction as mp3 files.
- 🔄 Playback auto-resume support for connection interruptions.
- 🛠️ REST API support (limited at the moment).
- 🚫 The bot cannot play YouTube streams.
- ⏸️ Playback auto-resume support creates noticeable pauses.
- ⏩ Sometimes playback speed is slightly faster than intended.
- 🐞 It's not bug-free.
You can test Melodix in two ways:
-
🖥️ Download compiled binaries (available only for Windows). Ensure FFMPEG is installed on your system and added to the global PATH variable (or specify the path to FFMPEG directly in the
.env
config file). Follow the "Create bot in Discord Developer Portal" section to set up the bot in Discord. -
🎙️ Join the Official Discord server and use the voice and
#bot-spam
channels.
Melodix Player supports various commands with respective aliases (if applicable). Some commands require additional parameters.
!play [title|url|stream|id]
(aliases:!p ..
,!> ..
) — Parameters: song name, YouTube URL, audio streaming URL, history ID.!skip
(aliases:!next
,!>>
) — Skip to the next track in the queue.!pause
(alias:!!
) — Pause playback.!resume
(aliases:!r
,!!>
) — Resume paused playback or start playback if a track was added via!add ..
.!stop
(alias:!x
) — Stop playback, clear the queue, and leave the voice channel.
!add [title|url|stream|id]
(aliases:!a
,!+
) — Parameters: song name, YouTube URL, audio streaming URL, history ID (same as for!play ..
).!list
(aliases:!queue
,!l
,!q
) — Show the current songs queue.
!history
(aliases:!time
,!t
) — Show history of recently played tracks. Each track in history has a unique ID for playback/queueing.!history count
(aliases:!time count
,!t count
) — Sort history by playback count.!history duration
(aliases:!time duration
,!t duration
) — Sort history by track duration.
!help
(aliases:!h
,!?
) — Show help cheatsheet.!help play
— Extra information about playback commands.!help queue
— Extra information about queue commands.!about
(alias:!v
) — Show version (build date) and related links.whoami
— Send user-related info to the log. Needed to set up superadmin in.env
file.
These commands are available only for superadmins (host server owners).
!curl [YouTube URL]
— Download as mp3 file for later use.!cached
— Show currently cached files (fromcached
directory). Each server operates its own files.!cached sync
— Synchronize manually added mp3 files to thecached
directory.!uploaded
— Show uploaded video clips in theuploaded
directory.!uploaded extract
— Extract mp3 files from video clips and store them in thecached
directory.
!register
— Enable Melodix command listening (execute once for each new Discord server).!unregister
— Disable command listening.melodix-prefix
— Show the current prefix (!
by default, see.env
file).melodix-prefix-update "[new_prefix]"
— Set a custom prefix (in quotes) for a guild to avoid collisions with other bots.melodix-prefix-reset
— Revert to the default prefix set in.env
file.
To use the play
command, provide a YouTube video title, URL, or history ID:
!play Never Gonna Give You Up
!p https://www.youtube.com/watch?v=dQw4w9WgXcQ
!> 5 (assuming 5 is an ID from `!history`)
For adding a song to the queue, use:
!add Never Gonna Give You Up
!resume
To add Melodix to a Discord server, follow these steps:
- Create an application in the Discord Developer Portal and obtain the
APPLICATION_ID
(in the General section). - In the Bot section, enable
PRESENCE INTENT
,SERVER MEMBERS INTENT
, andMESSAGE CONTENT INTENT
. - Use the following link to authorize the bot:
discord.com/oauth2/authorize?client_id=YOUR_APPLICATION_ID&scope=bot&permissions=36727824
- Replace
YOUR_APPLICATION_ID
with your Bot's Application ID from step 1.
- Replace
- Select a server and click "Authorize".
- Grant the necessary permissions for Melodix to function correctly (access to text and voice channels).
After adding the bot, build it from sources or download compiled binaries. Docker deployment instructions are available in docker/README.md
.
This project is written in Go, so ensure your environment is ready. Use the provided scripts to build Melodix Player from sources:
bash-and-run.bat
(or.sh
for Linux): Build the debug version and execute.build-release.bat
(or.sh
for Linux): Build the release version.assemble-dist.bat
: Build the release version and assemble it as a distribution package (Windows only).
Rename .env.example
to .env
and store your Discord Bot Token in the DISCORD_BOT_TOKEN
variable. Install FFMPEG (only recent versions are supported). If using a portable FFMPEG, specify the path in DCA_FFMPEG_BINARY_PATH
in the .env
file.
For Docker deployment, refer to docker/README.md
for specific instructions.
Melodix Player provides several API routes, subject to change.
GET /guild/ids
: Retrieve active guild IDs.GET /guild/playing
: Get info about the currently playing track in each active guild.
GET /history
: Access the overall history of played tracks.GET /history/:guild_id
: Fetch the history of played tracks for a specific guild.
GET /avatar
: List available images in the avatar folder.GET /avatar/random
: Fetch a random image from the avatar folder.
GET /log
: Show the current log.GET /log/clear
: Clear the log.GET /log/download
: Download the log as a file.
For any questions, get support in the Official Discord server.
I drew inspiration from Muzikas, a user-friendly Discord bot by Fabijan Zulj.
Melodix is licensed under the MIT License.