Skip to content
inspectsoftwarePublic

About

Free, open-source Discord music bot: YouTube, Spotify links, Apple Music, Deezer, Yandex, effects, radio, lyrics, quiz. Self-hosted with Docker Compose on Lavalink v4.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

Stoner

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.

Features

  • 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 .s prefix (.s play <song>).
  • Queues and radio survive a restart.

Run it

You need a machine with Docker and about 1.5 GB of free memory.

  1. In the Discord Developer Portal, create an application and add a bot. Copy the bot token and the application ID. To use the .s prefix, also turn on Message Content Intent on the Bot tab.
  2. Clone this repository and create your settings:
    git clone https://github.com/inspectsoftware/stoner.git && cd stoner
    cp .env.example .env
  3. In .env, fill in DISCORD_TOKEN and DISCORD_CLIENT_ID, and replace both change-me passwords with long random strings (for example openssl rand -hex 24). Set DEV_GUILD_ID to a test server's ID if you want commands to show up there at once while you try things out.
  4. Let Lavalink write its plugins folder (it runs as user 322):
    mkdir -p lavalink/plugins && sudo chown 322:322 lavalink/plugins
  5. Start everything:
    docker compose up -d --build
    docker compose logs -f bot
    Wait for Lavalink node main connected.
  6. 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 sign-in

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:

  1. Set YOUTUBE_OAUTH_ENABLED=true in .env and run docker compose up -d lavalink.
  2. docker compose logs lavalink shows a code. Enter it at https://www.google.com/device.
  3. Use a spare Google account, never your main one. YouTube may suspend accounts used this way.
  4. Lavalink then logs Token retrieved successfully with a refresh token (1//…). Put it in YOUTUBE_REFRESH_TOKEN and run docker compose up -d lavalink so 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.

Music sources

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.

Commands

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)

Prefix commands

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.

Now-playing card

Pause, skip, loop, shuffle and stop, volume down/up, and 👍 / 👎 for radio.

Leaving the channel

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.

DJ role and vote skip

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

/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.

Music quiz

/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.

Radio

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.

Development

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.ts

Pull requests are welcome. Please run npm test and npm run build first, and keep changes focused.

Roadmap

  • A second bot instance, so music can play in two voice channels of one server
  • Web dashboard

License

AGPL-3.0. If you run a modified version as a public bot, you have to share your changes under the same license.

About

Free, open-source Discord music bot: YouTube, Spotify links, Apple Music, Deezer, Yandex, effects, radio, lyrics, quiz. Self-hosted with Docker Compose on Lavalink v4.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages