Available Commands
MusicBot provides several commands to control music playback and manage the bot. All commands use the! prefix.
Command List
Music Playback Commands
!play
Plays audio from YouTube in your voice channel. Syntax:search_query(required): Either a YouTube URL or a search term
- Accepts both direct YouTube URLs (starting with
http://orhttps://) - For search queries, uses YouTube Data API v3 to find the first matching video
- Downloads audio in MP3 format at 192 kbps quality using yt-dlp
- Adds songs to a per-guild queue if something is already playing
- Automatically joins your voice channel if not already connected
- Uses per-guild caching (stored in
music/<guild_id>/directories) - Skips download if the video is already cached
- Returns error if you’re not in a voice channel
- Returns error for region-locked, private, or deleted videos
- Shows “Searching for…” message during search operations
- Notifies when using cached versions of songs
!skip
Skips the currently playing song and moves to the next in queue. Syntax:- Stops current playback immediately
- Triggers the
song_finishedcallback which plays the next queued song - If queue is empty, playback stops
- Handles edge cases where playback stopped but state wasn’t cleared
Voice Channel Management
!leave
Disconnects the bot from the voice channel and clears all data. Syntax:- Disconnects from the current voice channel
- Clears the entire song queue for the guild
- Resets playback state (current song, queue, timers)
- Cancels any active inactivity timers
- Deletes the entire guild cache directory (
music/<guild_id>/) - Removes all downloaded songs for that server
Utility Commands
!ping
Checks the bot’s voice connection latency. Syntax:- Measures round-trip latency to Discord voice server in milliseconds
- Only works when bot is connected to a voice channel
- Warns if latency exceeds 150ms
!author
Displays information about the bot author. Syntax:- Shows bot creator information
- Displays Discord username and GitHub profile link
!clearcache
Manually clears all downloaded songs for the current server. Syntax:- Deletes the guild-specific music directory (
music/<guild_id>/) - Removes all cached MP3 files for that server
- Prevents clearing cache if a song from cache is currently playing
- Requires stopping playback first if songs are playing
- Bot prevents cache clearing during active playback
- Use
!leaveor skip all songs before clearing cache if needed
Command Prefix
All commands use the! prefix, configured at bot.py:26:
Per-Guild Isolation
All playback state is isolated per-guild using theGuildPlayerState class (bot.py:29-46):
- Separate queues for each server
- Independent voice connections
- Isolated cache directories
- Individual inactivity timers
Inactivity Timeout
The bot automatically disconnects after 300 seconds (5 minutes) of inactivity (bot.py:25):- A new song starts playing
- The
!playcommand is used
Error Handling
All commands include comprehensive error handling:- User not in voice channel
- Bot in different voice channel
- Invalid or unavailable videos
- Network/API errors
- File system errors
- yt-dlp download errors
