A free, open-source Discord music bot. No paywalls, no vote walls, no premium tier. You host it yourself; everything runs from one docker compose up.
Built on Lavalink v4 with youtube-source, LavaSrc and LavaLyrics, plus discord.js, Postgres and Redis. Licensed under AGPL-3.0.
- Sources: YouTube and YouTube Music; Spotify links (track, album, playlist, artist) even without Spotify keys; Apple Music, Deezer and Yandex Music.
- Player: queue, skip, seek, restart, volume, shuffle, loop track/queue, move or remove tracks, and a now-playing card with buttons.
- Effects: bassboost (4 levels), nightcore, vaporwave, slowed, 8D, karaoke, tremolo, vibrato, low pass, speed, pitch, and an equalizer with presets.
- Radio: starts from a song, an artist or a genre and keeps the queue going; 👍 / 👎 and early skips steer it.
- Extras: live synced lyrics, saved playlists (per user and per server), a guess-the-song quiz, a sleep timer, play history and 24/7 mode.
- Server controls: an optional DJ role and vote skip.
- Two ways in: slash commands, or the
.sprefix (.s play <song>). - Queues and radio survive a restart.
You need a machine with Docker and about 1.5 GB of free memory.
- In the Discord Developer Portal, create an application and add a bot. Copy the bot token and the application ID. To use the
.sprefix, also turn on Message Content Intent on the Bot tab. - Clone this repository and create your settings:
git clone https://github.com/inspectsoftware/stoner.git && cd stoner cp .env.example .env
- In
.env, fill inDISCORD_TOKENandDISCORD_CLIENT_ID, and replace bothchange-mepasswords with long random strings (for exampleopenssl rand -hex 24). SetDEV_GUILD_IDto a test server's ID if you want commands to show up there at once while you try things out. - Let Lavalink write its plugins folder (it runs as user 322):
mkdir -p lavalink/plugins && sudo chown 322:322 lavalink/plugins - Start everything:
Wait for
docker compose up -d --build docker compose logs -f bot
Lavalink node main connected. - Invite the bot:
https://discord.com/oauth2/authorize?client_id=<DISCORD_CLIENT_ID>&scope=bot+applications.commands&permissions=3165184
To update later: git pull && docker compose up -d --build.
YouTube often blocks playback from data-center IPs ("This video requires login" in docker compose logs lavalink). If that happens, let Lavalink sign in with a Google account:
- Set
YOUTUBE_OAUTH_ENABLED=truein.envand rundocker compose up -d lavalink. docker compose logs lavalinkshows a code. Enter it at https://www.google.com/device.- Use a spare Google account, never your main one. YouTube may suspend accounts used this way.
- Lavalink then logs
Token retrieved successfullywith a refresh token (1//…). Put it inYOUTUBE_REFRESH_TOKENand rundocker compose up -d lavalinkso you only do this once.
Compose also runs yt-cipher, which decodes YouTube's stream signatures for Lavalink. The YouTube plugin is pinned to a youtube-source snapshot that has fixes not yet released; switch lavalink/application.yml back to a release once one newer than 1.18.2 is out.
YouTube and YouTube Music work out of the box. Apple Music works too: Lavalink fetches its token on its own. The others need *_ENABLED=true and their keys in .env, then docker compose up -d lavalink.
| Source | .env keys |
Where to get them |
|---|---|---|
| Spotify | SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, SPOTIFY_SP_DC (optional) |
Optional. Create an app at developer.spotify.com/dashboard; Spotify only serves its API when the app owner has Premium. sp_dc is a cookie from open.spotify.com, only needed for Spotify lyrics. |
| Deezer | DEEZER_ARL, DEEZER_MASTER_KEY |
arl is a cookie from deezer.com after you log in. For the master key, see the LavaSrc README. |
| Apple Music | APPLE_MUSIC_TOKEN (optional) |
Leave empty to auto-fetch. Set it only if auto-fetch breaks. |
| Yandex Music | YANDEX_TOKEN |
Follow the LavaSrc guide. The full catalogue needs a CIS country or Yandex Plus. |
With Spotify off, the bot still takes Spotify links: it reads the songs from Spotify's public embed page (up to 100) and plays each one from YouTube Music. A search on a source that isn't set up goes to YouTube Music. Spotify and Apple Music tracks play through a matching YouTube track (or Deezer, if that is set up). Use spare accounts for any cookies and tokens; they give access to the account. COUNTRY_CODE sets the region for Spotify and Apple Music.
SoundCloud is broken for now. SoundCloud only serves AAC/HLS streams, which lavaplayer (up to 2.2.7) can't play. See lavaplayer#204.
| Area | Commands |
|---|---|
| Play | /play (link or search, with autocomplete; optional source:), /queue, /nowplaying, /lyrics, /history |
| Voice | /join (your channel, or a channel ID, link or #mention; moves the bot if it is elsewhere), /leave |
| Control | /pause, /resume, /skip, /stop, /seek, /restart, /volume, /shuffle, /loop, /remove, /move, /clear |
| Effects | /effect, /speed, /pitch, /eq preset, /eq band, /reset (all effects off) |
| Radio | /radio start [song], /radio artist, /radio genre, /radio favourites, /radio stop, /radio fav add/remove/list |
| Playlists | /playlist create/add/save/remove/play/show/list/delete, each with scope: mine (default) or server |
| Fun | /quiz start [rounds] [genre] [playlist], /quiz stop, /quiz leaderboard, /sleep in/after-track/cancel |
| Server | /settings dj-role, /settings voteskip, /settings show, /247 (all need Manage Server) |
Every command also works with .s: .s play fakemink music and me, .s volume 80, .s playlist remove "road trip" 3. Arguments go in the slash command's order, the last text argument takes the rest of the line, and any argument can be named (source:deezer, genre:"2000s pop"). .s on its own lists the commands. This needs Message Content Intent; without it the bot runs on slash commands only.
Pause, skip, loop, shuffle and stop, volume down/up, and 👍 / 👎 for radio.
When the last person leaves, the bot says so and leaves too; with /247 on it stays and says so. It also leaves a channel that has had nobody in it for a minute, and leaves 3 minutes after the queue ends.
By default everyone can control playback. Set /settings dj-role to limit pause, stop, seek, volume, shuffle, loop, queue edits, effects, the sleep timer, stopping radio, and moving or disconnecting the bot while others listen, to that role and admins. Anyone alone with the bot counts as a DJ.
DJs and whoever queued a track skip at once. With /settings voteskip enabled:true, everyone else votes (50% of listeners by default). Server playlists can only be edited by DJs and admins.
/lyrics posts lyrics for the current track. When synced lyrics exist it keeps one message updated to the current line (every 5 seconds) and follows the queue; live:false posts them once. Lyrics come from Spotify (needs SPOTIFY_SP_DC), Deezer, Yandex Music, YouTube Music and LRCLIB.
/quiz start plays 20-second clips in your voice channel. Press Answer and type the title: 3 points plus up to 2 for speed, and the first correct title ends the round. The artist alone is worth 1 point. Songs come from a playlist, a genre search, or the server's play history (topped up with popular songs). Scores add up on /quiz leaderboard.
When the queue runs out, radio adds 5 more tracks similar to something that played recently. It looks for them in this order: the source's own recommendations (Deezer, Yandex, Spotify mixes), then Spotify by ISRC, then the YouTube mix for the track. Artist and genre radio also mix in search results for that artist or genre, so they don't drift.
It learns per server:
- 👍 on the card, or a track played to the end, makes that artist (and track) more likely.
- 👎, or skipping in the first 30 seconds, makes them less likely. Enough dislikes ban a track or artist from radio.
- Your favourite artists (
/radio fav add) get a boost when you started the radio.
It skips anything played in the last 50 tracks, livestreams, clips under a minute and mixes over 12 minutes, and plays at most 2 songs by one artist per batch.
The bot is TypeScript in bot/. Lavalink's config is lavalink/application.yml.
cd bot
npm install
npm test # vitest
npm run build # tsc
npm run db:generate # after changing src/db/schema.tsPull requests are welcome. Please run npm test and npm run build first, and keep changes focused.
- A second bot instance, so music can play in two voice channels of one server
- Web dashboard
AGPL-3.0. If you run a modified version as a public bot, you have to share your changes under the same license.