discord music bot · self-hosted · go · open source

Playback should survive.

Melodix streams YouTube, SoundCloud and internet radio into your Discord server — and treats every failure as a recoverable event. Flaky streams, dead voice connections, gateway reconnects: the music keeps playing.

$ go build ./cmd/discord && DISCORD_TOKEN=··· ./melodix-discord
Melodix BOT Today at 12:32
▶️ Now Playing
youtube ytnative-link 3:32 Rick Astley
melodix · logs

why it survives

Every track carries its own fallback chain.

Public music bots come and go, usually with a cease-and-desist attached. Melodix is the opposite deal: a small binary you run yourself, with your own token, on your own machine — built around the assumption that sources break, and that's fine.

When someone pastes a link, Melodix has to turn that web page into an actual audio stream it can pipe into a voice channel. The component that does this is called a parser — and YouTube fights it constantly, reshuffling its internals every few weeks. So Melodix never bets on a single one. It keeps a chain of parsers, ordered fastest-first, and walks down it until one delivers a playable stream. The panel above is that chain running live: the embed your users see, and the log stream underneath. Tap each backend to see what it actually is.

ytnative built in-house · zero deps

Melodix's own extractor, written for this project. It speaks YouTube's private InnerTube API — the same protocol the official phone and TV apps use — posing as the Android VR client, which hands back direct audio links with nothing to decrypt. No external programs, no embedded JavaScript engine: just plain HTTP calls from Go. It's the fastest route and the default. When YouTube eventually changes something, ytnative fails instantly instead of hanging, and the fix on our side is usually a single version number.

SoundCloud gets the same treatment through its own in-house extractor (scnative, built on SoundCloud's api-v2), and internet-radio URLs are handed straight to ffmpeg. Same idea everywhere: a fast native path first, sturdier fallbacks behind it.

survives discord too

A silent gateway or a dead voice connection is detected and recovered automatically. Queues live through session restarts.

keeps a memory

/history shows what was played; /play 42 replays entry 42. No link hunting.

stays small

One binary plus ffmpeg. Storage is a single JSON file — no database to babysit. Also runs as a terminal player, straight to your speakers.

quick start

Running in two minutes.

Discord bot

# token from the Discord Developer Portal
$ go build -o melodix-discord ./cmd/discord
$ DISCORD_TOKEN=your-token ./melodix-discord

Terminal player

# no Discord account required
$ go build -o melodix-cli ./cmd/cli
$ ./melodix-cli

You need FFmpeg in PATH; yt-dlp is optional (fallback only). Full setup — bot creation, invite link, every config knob, Docker — lives in docs/running.md.

commands

Eight commands. Simple to maintain.

/playlink, search query, radio URL, or history id
/nextskip to the next track
/stopstop playback and clear the queue
/historyrecently played tracks, replayable by id
/helpcommands by category, group, or flat
/settingsenable or disable command groups per server
/maintenanceping, stats, database download
/aboutwhere this bot came from

Try it live in the Ctrl+Z server — join a voice channel and play something in #music-spam. Or browse the full command reference on GitHub.

downloads

Prebuilt binaries.

Each bundle ships both binaries, a ready-to-edit .env, and the docs. Or run it in Docker.