A simple Discord bot to play music from YouTube, manage a queue, and control playback in voice channels.
- Play audio from YouTube URLs.
- Queue management (add, view, skip, clear).
- Control playback (pause, resume, stop).
- Join and leave voice channels automatically.
Before running the bot, make sure you have the following:
- Python 3.8 or later.
- The required Python packages:
discord.py
yt-dlp
python-dotenv
PyNaCl
ffmpeg
(installed on your system and added to PATH).
- Clone the repository or copy the script.
git clone https://github.com/clueNA/MSCBOT
- Install the required dependencies:
pip install discord.py yt-dlp python-dotenv pynacl
- Install
ffmpeg
:- On Windows: Download from FFmpeg and add to PATH.
- On macOS: Use Homebrew:
brew install ffmpeg
. - On Linux: Install via your package manager:
sudo apt install ffmpeg
.
- Create a
.env
file in the project directory with your Discord bot token:echo DISCORD_TOKEN=your_token_here > .env
- Run the bot:
python music_bot.py
Command | Description |
---|---|
!help |
Show all available commands. |
!join |
Bot joins your voice channel. |
!leave |
Bot leaves the voice channel. |
Command | Description |
---|---|
!play <url> |
Play or queue audio from a YouTube URL. |
!queue |
Display the current queue. |
!skip |
Skip the currently playing song. |
!np |
Shows information about the currently playing track |
!clear |
Clear the queue. |
!loop |
Changes loop mode (off/track/queue). |
!pause |
Pause the current song. |
!resume |
Resume the paused song. |
!stop |
Stop playback and clear the queue. |
- Join a voice channel.
- Use
!play <YouTube URL>
to start playing music. - Use
!queue
to view the current queue. - Manage playback with commands like
!skip
or!pause
.
-
Error: "Could not extract video data"
- Ensure the YouTube URL is valid, and
yt-dlp
is installed and up-to-date.
- Ensure the YouTube URL is valid, and
-
Bot does not join voice channel:
- Verify you are in a voice channel and the bot has permission to join.
-
Bot does not respond:
- Ensure the bot is running, and the token in
.env
is correct.
- Ensure the bot is running, and the token in
discord.py
: For Discord API integration.yt-dlp
: For YouTube video and audio extraction.FFmpeg
: For audio processing.PyNaCl
: For voice support in discord.py.