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

Playback should survive.

Melodix streams YouTube, SoundCloud and internet radio into your Discord server. It treats every failure as something to recover from, not something to crash on — a flaky stream, a dead voice connection, a gateway reconnect. The music just 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 tend to disappear eventually, usually with a cease-and-desist attached. Melodix skips that risk: it's a small binary you run yourself, with your own token, on your own machine. Sources break sometimes. That's just assumed going in, not treated as a special case.

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 doesn't bet everything on one parser. It keeps a chain of them, ordered fastest-first, and works down the list until one returns a playable stream. The panel above shows that chain running live: the embed your users would see, and the log underneath it. Click a backend below for what it actually does.

ytnative built in-house · zero deps

Melodix's own extractor, written specifically for this project. It speaks YouTube's private InnerTube API — the same protocol the official phone and TV apps use — pretending to be the Android VR client, which hands back direct audio links with nothing to decrypt. No external programs and no embedded JavaScript engine, just plain HTTP calls from Go. It's the fastest route and the default one. When YouTube changes something, which it will, ytnative tends to fail instantly rather than hang, and fixing it is usually a one-line version bump.

SoundCloud gets similar treatment through its own in-house extractor, scnative, built on SoundCloud's api-v2. Internet-radio URLs skip straight to ffmpeg, since there's nothing to extract there in the first place. The pattern repeats: try the fast native path, keep sturdier fallbacks in reserve.

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.