Music Bot Commands
The reference bot (examples/musicbot/) serves every community the account belongs to. Commands are typed in any watched text channel; the bot replies in the same channel. While the bot is playing, see the in-voice gate below.
Command list
| Command | What it does |
|---|---|
!play <url or search> | Play or queue a track. Search terms and YouTube URLs resolve through Lavalink; a direct URL plays through the framework fetcher (and only when the operator enabled it). See below. |
!pause | Pause playback, preserving position exactly. |
!resume | Resume a paused track. |
!skip | Stop the current track and move to the next queued one. |
!stop | Clear the queue, stop playback, and leave voice immediately. Also suppresses autoplay. |
!queue | Show the queue as a text card (current track + up to 10 queued, then "…and N more"). |
!np | Show the now-playing card with live, pause-adjusted progress. |
!vol | Show the current volume. |
!vol <0-100> | Set volume (clamped to 0–100). Applies live, mid-track, and persists across tracks. |
!loop | Cycle loop mode: off → track → queue → off. |
!loop <off|track|queue> | Set loop mode directly. track replays the current track; queue re-appends it to the end. Skipping never re-appends. |
!shuffle | Smart-shuffle the queue (see below). |
!autoplay | Toggle autoplay. !autoplay on / !autoplay off set it explicitly. Default off. |
!remove <n> | Remove queue entry n (1-based, as shown by !queue). |
!clear | Empty the queue (the current track keeps playing). |
!ping | Replies pong. The fastest "is it alive" check. |
!help | Post the one-line command summary. |
!play in detail
A YouTube URL (watch,
youtu.be, shorts, embed, live) is resolved through Lavalink and queued. If nothing is playing, playback starts immediately; otherwise the bot confirms withQueued #n: <title>.A direct URL (any other host) is refused unless the operator enabled
allow_direct_urls. When enabled, its track info is resolved through Lavalink like everything else, but playback itself goes through the framework's validating fetcher (rootbot.voice.fetch), never through Lavalink or yt-dlp: the URL is resolved once, checked, pinned and fetched by the framework, and a URL the fetcher rejects does not play. See "Which path guards what" in the plugin guide.A playlist URL enqueues every track and confirms with
Queued playlist: N tracks.Search terms return the top 5 Lavalink results as a picker:
🔎 Pick a track (reply 1-5) 1. Never Gonna Give You Up (3:33) 2. …Reply with a bare digit (
1–5). The pick is bound to you, in that channel, for 60 seconds, other people's digits are ignored, and an expired pick is silently dropped. A search with exactly one result skips the picker and queues it directly.Playback starts only after the follow-me check finds you in a voice channel.
Follow-me
The bot has no fixed voice channel. When a !play needs it to join, it presence-checks every voice channel in the community the command came from and joins the one you are sitting in. If you are in no voice channel there, it replies "Join a voice channel first, then !play." and queues nothing.
The in-voice gate
While the bot is in a voice channel, it only accepts commands, picker digit replies included, from members of that channel. Anyone else gets "Join my voice channel to control the bot." When the bot is not in voice, commands are accepted from anyone (that's how !play itself can work). If the presence check errors, the gate fails open.
Smart shuffle
!shuffle is not a coin flip. It greedily reorders the queue to spread artists apart: at each step it places the most-frequent remaining author whose author differs from the track just placed, and the first track placed avoids the currently playing track's author when possible. Queues of one or two tracks pass through unharmed. The bot confirms with "Smart-shuffled the queue."
Autoplay
With autoplay on, whenever playback would otherwise end, the queue empties after a natural finish or a skip-to-empty, the bot refills from the YouTube Mix (RD… radio playlist) of the last played track:
- Up to 5 tracks are enqueued at a time; as they drain, it refills again from the new last track.
- The just-played track and anything played in the last 10 tracks are filtered out, as are duplicates inside the mix.
- It announces
Autoplay: queued related tracks. If nothing survives the filter (or the last track has no YouTube id, or the mix fails to load), it announcesAutoplay: no related tracks found.once and playback ends normally, no retry loop. !stophard-suppresses autoplay. Loop modes never trigger it, because the queue never truly empties.
Autoplay state lasts for the serve session only.
Text cards
Root user messages are plain text, so status output is formatted as embed-style text cards. The now-playing card (posted on every track start, and by !np with live progress):
🎵 Now Playing
Feel The Heat - SEGA Bass Fishing Music (HD)
▰▰▰▰▱▱▱▱▱▱ 1:24 / 3:35 • Vol 80 • Queue: 4The progress bar is 10 cells, filled in proportion to elapsed/duration. !queue uses a 📜 Queue, N tracks header, a ▶ line for the current track, and numbered entries with durations.
Idle auto-leave
When the queue drains, the bot stays in voice for 5 minutes before leaving. A new !play in that window cancels the timer and reuses the connection. !stop leaves immediately instead.
Running modes
python -m examples.musicbot.musicbot serve # the resident bot
python -m examples.musicbot.musicbot # join test: SessionCreate + join, then leave
python -m examples.musicbot.musicbot tone # join and play a 10 s test tone
python -m examples.musicbot.musicbot play <url> # join and play one trackThe non-serve modes use the community_id / container_id pair from config.json as the join target.