A simple music bot for Discord written in Python using discord.py and yt-dlp. It allows users to play music from YouTube, manage queues, skip tracks, and stop the bot from playing music. Additionally, it includes a fun "777" game feature where users can place bets and spin virtual fruit symbols.
- Music Playback: Play audio from YouTube links directly in a voice channel.
- Queue Management: Add songs to a queue and skip or stop songs.
- 777 Game: Play a simple slot machine game with bets and rewards.
- PLAYLISTS: ADD PLAYLIST
- Bot Commands: Interact with the bot through a variety of commands to control playback and play games.
chmod +x install.bash
sudo ./install.bash- Python 3.10
- Required Python packages:
discord.pyyt-dlpffmpeg(for audio processing)
git clone https://github.com/your-username/discord-music-bot.git
cd discord-music-botpython -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`pip install -r requirements.txtsudo apt update
sudo apt upgrade
sudo apt install ffmpegYou can download FFmpeg from here. Make sure to add FFmpeg to your system's PATH variable.
To configure your bot in the Discord Developer Portal, follow these steps:
- Log in to your Discord account.
- Go to the Discord Developer Portal.
- Click the New Application button.
- Enter a name for your application (e.g., "MyMusicBot") and click Create.
- In the left menu, click Bot.
- Click Add Bot and confirm by clicking Yes, do it!.
- Your bot will now be created, and here you can change its name, profile picture, and other settings.
- On the bot settings page, under the Bot section, you will see the TOKEN field.
- Click the Copy button next to Token.
- The token is crucial for running the bot in your code — keep it in a secure place.
For the bot to work correctly, you need to assign it the appropriate permissions.
- Under the Bot section, scroll down to Privileged Gateway Intents.
- Enable the following permissions:
- MESSAGE CONTENT INTENT – Allows the bot to read message content (important if the bot uses commands).
- SERVER MEMBERS INTENT – Allows the bot to manage server members if needed.
To invite the bot to your server, you need to generate the appropriate invite link.
-
Go to the OAuth2 section in the left menu.
-
In the OAuth2 URL Generator, select the following scopes:
- bot under SCOPES.
- Select the required permissions under BOT PERMISSIONS.
At a minimum, choose the following permissions:
- Read Messages
- Send Messages
- Connect (to join voice channels)
- Speak (to speak in voice channels)
-
Copy the generated URL and open it in your browser to invite the bot to your server.
- If the bot is going to be public, make sure to use environment variables or configuration files to store your bot token, preventing it from being exposed.
- Use additional protection mechanisms, such as Two-Factor Authentication (2FA), to secure your bot's account.
- After generating the token, use it in your bot's code (e.g.,
bot.run('YOUR_BOT_TOKEN')). - Run your bot on your server to check if it's working properly.
- Run the bot: To start the bot, simply run the Python script:
python3.10 bot.py- !play : Add a song to the queue and start playing it.
- !add : Add a song to the queue without starting playback.
- !skip: Skip the current song and play the next one in the queue.
- !stop: Stop the music and clear the queue.
- !queue: Show the current song queue.
- !leave: bot leave a channel
- !join: bot join a channel
- !clear: clear queue and folder downloads
- !777 <bet_amount>: Play a simple slot game with a bet. Win if all three symbols match.
- !playlist
- !addplaylist <"NAME">
- !HELP: informations
Make sure the bot has permission to join and speak in the voice channel, and the necessary permissions to read and send messages.
License This project is licensed under the MIT License - see the LICENSE file for details.
Notes Make sure you have the ffmpeg library installed, as it is required for audio playback in Discord. If the bot encounters issues with downloading audio from YouTube, ensure that yt-dlp is installed and updated properly.