A simple yet functional Discord bot written in Rust that can play music from YouTube in voice channels. Built using the Serenity and Songbird libraries.
- Join voice channels (
!join
) - Play music from YouTube URLs (
!play
) - Leave voice channel (
!leave
) - Automatic volume control
- Status messages with emojis
- Robust error handling
Before running the bot, make sure you have the following installed:
# Using Homebrew
brew install rust
brew install yt-dlp
brew install ffmpeg
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install yt-dlp and ffmpeg
sudo apt update
sudo apt install yt-dlp ffmpeg
- Create a new application in the Discord Developer Portal
- Create a bot for your application and copy the token
- Replace
"PLACE_YOUR_TOKEN_HERE"
insrc/main.rs
with your token - Invite the bot to your server using the OAuth2 URL generated in the portal
# Clone the repository
git clone [email protected]:louire/discord_plays.git
cd discord_plays
# Build and run
cargo run
Once the bot is online, you can use the following commands:
!join
- Bot joins your current voice channel!play <url>
- Plays audio from a YouTube video!leave
- Bot leaves the voice channel
Example:
!play https://www.youtube.com/watch?v=dQw4w9WgXcQ
If you encounter issues:
- Verify all dependencies are installed:
yt-dlp --version
ffmpeg -version
-
Ensure the bot has the necessary Discord permissions:
- Connect (to voice channels)
- Speak
- Send Messages
-
Check that the YouTube URL is valid and accessible
-
Review console logs for error messages
Features and improvements we plan to add:
- Search functionality: Allow users to search songs by name instead of requiring the exact URL
- Track selection: Show top 5 results when searching and let users choose
- Queue system: Add ability to queue multiple songs
- Skip command: Add ability to skip current track
- Volume control: Add command to adjust volume during playback
- Playlist support: Allow playing entire YouTube playlists
- Save favorites: Let users save their favorite songs
- Song info display: Show current song title, duration, and progress
- Error recovery: Auto-reconnect on disconnection
- Permissions system: Add DJ role and admin commands
Contributions are welcome! Here's how you can help:
- Pick an item from the TODO list
- Open an issue to discuss your implementation
- Fork the repository
- Create a new branch for your feature
- Submit a pull request
Please ensure your code:
- Follows the existing code style
- Includes appropriate comments
- Has been tested thoroughly
- Updates the README if adding new commands
This project is licensed under the MIT License - see the LICENSE.md file for details.