π΅ A powerful, modular Discord bot with interactive music player, entertainment commands, and utility features!
| Category | Features | Status |
|---|---|---|
| π΅ Music | Interactive Player, Queue Management, Spotify Integration | β Active |
| π Entertainment | Games, Memes, Fun Commands | β Active |
| π Search | Web Search, Topic Research | β Active |
| π οΈ Utility | User Management, Server Stats | β Active |
| π Moderation | Auto-moderation, Logging | β Active |
Screenshot of the interactive music player with queue management
Our music system provides a premium Discord music experience with:
Our music system combines the best of both platforms for an optimal experience:
π΅ Spotify Integration (Metadata & Discovery):
- Rich Metadata - Song titles, artists, album art, duration
- High-Quality Thumbnails - Beautiful album artwork
- Smart Search - Spotify's powerful search algorithm
- Artist Information - Detailed track and artist data
- Popularity Metrics - Track popularity and recommendations
π₯ YouTube Integration (Audio Playback):
- High-Quality Audio - Streams actual audio via yt-dlp
- Reliable Playback - Stable audio streaming
- Wide Availability - Most songs available on YouTube
- Direct URL Support - Play YouTube links directly
- Format Optimization - Best audio quality extraction
1. User searches: "Bohemian Rhapsody"
β
2. Spotify API: Finds metadata, thumbnail, artist info
β
3. YouTube Search: Finds matching audio using Spotify metadata
β
4. yt-dlp: Extracts high-quality audio stream
β
5. Discord: Plays audio with Spotify's rich information
- Hybrid Search - Spotify metadata + YouTube audio
- Real-time Updates - Live status changes with rich embeds
- Smart Matching - Automatically matches Spotify tracks to YouTube audio
- Fallback System - Falls back to YouTube-only search if Spotify fails
- Queue Persistence - Maintains queue across sessions with full metadata
- Volume Memory - Remembers volume settings per server
- Format Selection - Automatically selects best audio quality
| Command | Description | Example |
|---|---|---|
!music |
π΅ Launch interactive music player | !music |
!play <song> |
!play Never Gonna Give You Up |
|
!search <song> |
π Quick search and play | !search Tere Bina |
!pause |
βΈοΈ Pause current song | !pause |
!resume |
!resume |
|
!skip |
βοΈ Skip to next song | !skip |
!stop |
βΉοΈ Stop music and clear queue | !stop |
!queue |
π Show current queue | !queue |
!volume <0-100> |
π Set volume level | !volume 75 |
!loop |
π Toggle loop mode | !loop |
!leave |
π Leave voice channel | !leave |
!nowplaying |
π΅ Show current song info | !nowplaying |
Our music system uses a sophisticated hybrid approach that leverages both platforms:
-
User Input Processing
# User searches for a song query = "Tere Bina"
-
Spotify Metadata Retrieval
# Get rich metadata from Spotify spotify_result = spotify.search(query, type='track', limit=1) metadata = { 'title': track['name'], 'artist': track['artists'][0]['name'], 'album': track['album']['name'], 'thumbnail': track['album']['images'][0]['url'], 'duration': track['duration_ms'] // 1000, 'popularity': track['popularity'] }
-
YouTube Audio Search
# Search YouTube using Spotify metadata for better accuracy youtube_query = f"{metadata['title']} {metadata['artist']}" youtube_url = await YTDLSource.search_youtube_for_audio(youtube_query)
-
Audio Stream Extraction
# Extract high-quality audio stream using yt-dlp player = await YTDLSource.from_url(youtube_url, stream=True)
-
Discord Playback
# Play audio with rich Spotify metadata display voice_client.play(player) embed = create_rich_embed(metadata) # Beautiful Spotify-style card
- Spotipy - Spotify Web API wrapper for metadata
- yt-dlp - YouTube audio extraction and streaming
- discord.py - Discord bot framework with voice support
- asyncio - Asynchronous processing for smooth performance
- SQLite - Local database for queue and settings persistence
async def smart_music_search(query):
try:
# Primary: Spotify + YouTube hybrid
spotify_data = await get_spotify_metadata(query)
youtube_url = await search_youtube_with_metadata(spotify_data)
return combine_data(spotify_data, youtube_url)
except SpotifyException:
# Fallback: YouTube-only search
return await youtube_only_search(query)
except YouTubeException:
# Fallback: Direct URL or alternative sources
return await fallback_search(query)# Required
- Python 3.8+
- Discord Bot Token
- Voice Channel Permissions
# Optional (for full features)
- Spotify API Credentials
- Google Gemini API Key# Clone the repository
git clone <your-repo-url>
cd Discord-bot-
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtCreate a .env file in the project root:
DISCORD_TOKEN=your_discord_bot_token_here
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
GEMINI_API_KEY=your_gemini_api_key# Activate virtual environment
source venv/bin/activate
# Start the bot
python3 main_bot.py- Hybrid Integration: Combines Spotify's rich metadata with YouTube's audio streaming
- Interactive UI: Discord buttons, modals, and embeds for seamless user experience
- Smart Queue Management: Add, remove, shuffle, and clear songs with ease
- Persistent Settings: Volume and preferences saved per server
- Real-time Updates: Live status changes reflected instantly
- Web Integration: Real-time web search capabilities
- Context Awareness: Understands natural language queries
- Private Responses: Use
?prefix for private command responses
- Comprehensive Stats: Detailed server analytics and member information
- Auto-moderation: Spam detection and content filtering
- Logging System: Complete audit trail of server activities
- Permission Management: Role-based command access control
# Audio quality settings
YTDL_FORMAT_OPTIONS = {
'format': 'bestaudio/best',
'quality': 'highest',
'audio_format': 'mp3'
}
# Default volume (0.0 to 1.0)
DEFAULT_VOLUME = 0.5
# Queue limits
MAX_QUEUE_SIZE = 100# Spam detection
SPAM_THRESHOLD = 5 # Messages per time window
SPAM_TIME_WINDOW = 10 # Seconds
# Bad words filter (customize as needed)
BAD_WORDS = ['spam', 'scam', 'hack']We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
# Clone your fork
git clone https://github.com/yourusername/Discord-bot-.git
cd Discord-bot-
# Set up development environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run tests (if available)
python -m pytest tests/π΅ Music not playing
Solutions:
- Check bot has voice channel permissions
- Ensure
yt-dlpis properly installed - Verify Spotify API credentials (if using)
- Check if voice channel is full
π Bot not responding to commands
Solutions:
- Verify bot token in
.envfile - Check bot has message read permissions
- Ensure bot is online and connected
- Check command prefix (
!for most commands)
π¦ Dependency installation issues
Solutions:
- Use virtual environment:
python3 -m venv venv - Upgrade pip:
pip install --upgrade pip - Install with user flag:
pip install --user -r requirements.txt - Check Python version (3.8+ required)
- π§ Email: [sreeshanthsoma@gmail.com]
- π¬ Discord - username: [sreeshu_soma]
- π Issues: Issues
After 3 hours of:
- β 15+ failed container deployments
- β 6 different regions tried
- β Syntax errors in inline Python
- β Environment variable mysteries
- β "RequestDisallowedByAzure" nightmares
- β Containers that start but don't connect
- β Our sanity slowly disappearing
Azure: "Have you tried turning it off and on again?" π€
Us: "WE'RE SWITCHING TO RAILWAY!" πββοΈπ¨
Railway: "Hi there! Want to deploy a Discord bot?"
Us: "Please don't hurt us..." π°
Railway: "Just push to GitHub and add your env vars!"
Us: "That's... that's it?" π€
Railway: "Yep! deploys in 2 minutes β¨"
Us: "...IT'S ALIVE! IT'S ACTUALLY ONLINE!" π
Sometimes the simplest solution is the best solution. Railway proved that deploying a Discord bot doesn't have to involve:
- Reading 47 Azure documentation pages
- Debugging container orchestration
- Questioning your life choices
- Crying into your keyboard
**The bot is now happily running on Railway, serving Discord users.
P.S. - If you're thinking about Azure for your Discord bot... maybe try Railway first. Your mental health will thank you. π
Made with β€οΈ for the Discord community (and Railway for actually working!)