This project is a Discord bot developed in Python using the discord.py
library. The bot allows users to play music directly in their Discord servers, offering commands to play, pause, resume, and stop music, as well as to join and leave voice channels.
- Play music from provided URLs.
- Pause, resume, and stop music playback.
- Automatically join and leave voice channels as needed.
Ensure you have the following installed in your environment:
- Python 3.6 or higher.
- A Discord account and a server where you have permissions to add bots.
- FFmpeg installed and available in the system PATH.
-
Clone the repository:
git clone https://github.com/lucasfelipecastro/discord-bot cd discord-bot
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
-
Install the dependencies:
pip install discord.py python-dotenv yt-dlp
-
Configure the Bot Token:
Create a
.env
file in the project's root directory and add your bot's token:DISCORD_TOKEN=your_token_here
Note: To obtain your bot's token, you need to create an application in the Discord Developer Portal and add a bot to your application.
-
Install FFmpeg:
The bot uses FFmpeg for audio handling. Ensure that FFmpeg is installed and available in the system PATH. You can download it from:
After completing the installation steps, start the bot with the following command:
python your_script.py
Replace your_script.py with the name of the file containing the bot's code.
In Discord, you can interact with the bot using the following commands:
.play <URL>
: The bot will play the audio from the provided URL..pause
: Pauses the current playback..resume
: Resumes paused playback..stop
: Stops audio playback..join
: The bot will join your current voice channel..leave
: The bot will leave the voice channel.
*Note: Ensure that the bot has the appropriate permissions on the server and that you are in a voice channel when using audio-related commands.
Contributions are welcome! Feel free to open issues and pull requests for improvements or fixes.
This project is licensed under the MIT License. See the LICENSE file for more details.