Skip to content

Advanced Discord music bot with YouTube & Spotify support, featuring bot protection bypass, multi-client extraction strategies, and container-optimized deployment for Railway/Docker environments.

License

Notifications You must be signed in to change notification settings

last-26/Discord-MusicBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽต MyDJ26 - Advanced Discord Music Bot

MyDJ26 - Modern Discord music bot with YouTube and Spotify support, featuring YouTube bot protection bypass and container optimization.

Python Discord.py License

๐Ÿ”ฅ Latest Major Update

โœจ What's New in This Release:

๐Ÿ›ก๏ธ YouTube Bot Protection Solutions

  • ๐Ÿ”„ Invidious Backup System - Automatically switches to alternative YouTube frontends when main YouTube fails
  • ๐Ÿค– Multi-Client Strategy - Tries Android, Web, and Basic clients for maximum compatibility
  • ๐Ÿ”€ User-Agent Rotation - Uses different browser identities to avoid detection
  • ๐Ÿณ Container Optimization - Specially optimized for Railway/Docker cloud deployment

๐Ÿ”’ Security & Code Quality Improvements

  • โŒ Removed Hardcoded Tokens - All sensitive data now uses environment variables
  • ๐ŸŒ International Code Standards - Comments and documentation converted to English
  • ๐Ÿ› ๏ธ Enhanced Error Handling - Specific solutions for each error type
  • ๐Ÿ“ Professional Documentation - Comprehensive README with troubleshooting guides

๐ŸŒ User Experience Enhancements

  • International Interface - Full English interface with Turkish command aliases
  • ๐Ÿ“Š Advanced Status Command - Detailed bot statistics with +status
  • โ“ Comprehensive Help System - Complete command guide with +commands
  • ๐Ÿ”„ Smart Fallback System - Automatically tries next method when one fails
  • ๐Ÿ‡น๐Ÿ‡ท Turkish Command Support - Turkish aliases for all commands (e.g., +cal for +play)

๐ŸŽต Music Features

  • ๐Ÿ“ Enhanced Lyrics System - Integration with lyrics.ovh API
  • โญ๏ธ Smart Queue Management - Continues to next song on errors
  • ๐ŸŽถ Multiple Format Support - M4A, WebM, MP4 compatibility
  • ๐Ÿ”Š Improved Audio Quality - Better audio extraction strategies

๐Ÿš€ Ready for Production: This update makes the bot significantly more reliable against YouTube restrictions and ready for cloud deployment!

โœจ Features

๐Ÿš€ Core Features

  • ๐ŸŽต YouTube and Spotify support - Play using links or search by song name
  • ๐ŸŽถ Smart queue system - Sequential playback and advanced queue management
  • โฏ๏ธ Full playback control - Pause, resume, skip, stop commands
  • ๐Ÿ”€ Queue shuffling - Random playback feature
  • ๐Ÿ“ Song lyrics - Real-time lyrics fetching from lyrics.ovh API
  • ๐Ÿงน Message cleanup - Channel management commands
  • ๐Ÿ”Š Auto voice channel management - Smart connection and switching

๐Ÿ›ก๏ธ YouTube Bot Protection Bypass

  • ๐Ÿ”„ Invidious Backup System - Alternative servers when YouTube fails
  • ๐Ÿค– Multi-Client Strategy - Android, Web, and Basic client attempts
  • ๐Ÿ”€ User-Agent Rotation - Different browser identities
  • ๐Ÿณ Container Optimization - Specially optimized for Railway/Docker

๐ŸŒ Advanced Features

  • ๐Ÿ‡น๐Ÿ‡ท Turkish Interface - Full Turkish user interface support
  • ๐Ÿ“Š Bot Status - Detailed bot statistics with +status command
  • โ“ Help System - Comprehensive help menu with +komutlar
  • ๐Ÿ›ก๏ธ Smart Error Handling - Each error type has specific solution suggestions
  • ๐Ÿ”„ Automatic Fallback - If one method fails, try the next
  • โญ๏ธ Queue Management - Continue to next song on error

๐Ÿš€ Quick Start

Requirements

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/MyDJ26.git
    cd MyDJ26
  2. Install required packages:

    pip install -r requirements.txt
  3. Create environment file:

    cp env.example .env
  4. Add your Discord Bot Token:

    • Open the .env file
    • Replace your_discord_bot_token_here with your actual token
    DISCORD_BOT_TOKEN=YOUR_ACTUAL_TOKEN_HERE
    
  5. Run the bot:

    python music_bot.py

๐ŸŽฎ Commands

Music Commands

Command Aliases Description
+play <song/link> +p, +cal, +oynat Plays YouTube/Spotify links or searches by song name
+queue +q, +kuyruk Shows the music queue
+skip +s, +atla Skips the current song
+shuffle +karistir Shuffles the queue
+pause +dur Pauses the music
+resume +devam Resumes the music
+stop +durdur Stops music and clears queue
+disconnect +leave, +dc, +ayril Disconnects from voice channel

Utility Commands

Command Aliases Description
+lyrics [song] +lyric, +sozler Gets song lyrics (leave empty for current song)
+status +durum Shows bot status and statistics
+commands +help, +komutlar, +yardim Shows command list and help
+clear [number] +c, +clean, +temizle Deletes specified number of messages (default: 10)

Usage Examples

# Play YouTube video (English/Turkish)
+play https://www.youtube.com/watch?v=dQw4w9WgXcQ
+cal https://www.youtube.com/watch?v=dQw4w9WgXcQ

# Play Spotify song
+play https://open.spotify.com/track/4iV5W9uYEdYUVa79Axb7Rh

# Search by song name (English/Turkish)
+play imagine dragons believer
+oynat imagine dragons believer

# Queue control (English/Turkish)
+queue / +kuyruk
+skip / +atla
+shuffle / +karistir

# Music control (English/Turkish)
+pause / +dur
+resume / +devam
+stop / +durdur

# Song lyrics (English/Turkish)
+lyrics bohemian rhapsody / +sozler bohemian rhapsody
+lyrics  # (lyrics for currently playing song)

# Bot status and help (English/Turkish)
+status / +durum
+commands / +komutlar

๐Ÿ› ๏ธ Advanced Configuration

YouTube Bot Protection Solutions

This bot includes several strategies to handle YouTube's bot detection:

  1. Invidious Instances - Uses alternative YouTube frontends
  2. Multiple Extraction Strategies - Tries different clients (Android, Web)
  3. Format Flexibility - Supports M4A, WebM, MP4 formats
  4. Container Environment - Optimized for Docker/Railway deployment

Invidious Instances Used:

  • https://invidious.fdn.fr
  • https://invidious.privacydev.net
  • https://invidious.lunar.icu
  • https://iv.melmac.space
  • https://invidious.slipfox.xyz

๐Ÿณ Running with Docker

# Build Docker image
docker build -t mydj26 .

# Run container (requires .env file)
docker run --env-file .env mydj26

โ˜๏ธ Deploy to Railway

Railway is a modern cloud platform that makes deployment simple and fast.

  1. Create a Railway account:

  2. Deploy from GitHub:

    • Go to Railway Dashboard
    • Click "New Project"
    • Select "Deploy from GitHub repo"
    • Choose your repository
    • Railway will automatically detect it's a Python project
  3. Add Environment Variables:

    • In your Railway project dashboard
    • Go to "Variables" tab
    • Add: DISCORD_BOT_TOKEN = your_actual_token_here
  4. Deploy:

    • Railway will automatically build and deploy your bot
    • Your bot will be live in seconds!

Railway Features:

  • โœ… Automatic deploys - Pushes to main branch auto-deploy
  • โœ… Free tier - Great for small bots
  • โœ… Easy scaling - Upgrade when needed
  • โœ… Built-in monitoring - Logs and metrics included

๐Ÿ“‹ Discord Bot Setup

  1. Go to Discord Developer Portal
  2. Click "New Application"
  3. Give your application a name
  4. Go to the "Bot" tab
  5. Click "Add Bot"
  6. Copy the token from the "Token" section
  7. Enable "Message Content Intent" under "Privileged Gateway Intents"

Bot Permissions

When adding the bot to your server, it needs these permissions:

  • โœ… Send Messages
  • โœ… Connect (to voice channels)
  • โœ… Speak (in voice channels)
  • โœ… Use Voice Activity
  • โœ… Manage Messages (for clear command)

๐Ÿ”ง Troubleshooting

Common Errors

"DISCORD_BOT_TOKEN environment variable not found!"

  • Make sure the .env file is created correctly
  • Verify the token is copied correctly without quotes

"YouTube bot protection is active!"

  • Wait 5-10 minutes and try again
  • Use shorter and simpler song names
  • Try using VPN from different location
  • The bot will automatically try Invidious instances

"Cannot connect to voice channel"

  • Check bot's voice channel permissions
  • Make sure FFmpeg is installed correctly
  • Try different voice channel
  • Check server voice region settings

"All extraction strategies failed"

  • 3 different client strategies were attempted
  • Invidious backup system also failed
  • Wait 10-15 minutes and try again
  • YouTube may be experiencing heavy restrictions

๐Ÿ› ๏ธ Development

Project Structure

MyDJ26/
โ”œโ”€โ”€ music_bot.py          # Main bot file
โ”œโ”€โ”€ requirements.txt      # Python dependencies
โ”œโ”€โ”€ env.example          # Example environment file
โ”œโ”€โ”€ .gitignore           # Git ignore rules
โ”œโ”€โ”€ Dockerfile           # Docker container definition
โ”œโ”€โ”€ Procfile             # Railway deployment
โ””โ”€โ”€ README.md            # This file

Contributing

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“Š Stats

  • ๐ŸŽต Multi-format support: M4A, WebM, MP4
  • ๐Ÿ”„ 5 Invidious instances for reliability
  • ๐Ÿค– 3 extraction strategies for YouTube
  • ๐Ÿ‡น๐Ÿ‡ท Full Turkish interface support
  • ๐Ÿณ Container optimized for cloud deployment

About

Advanced Discord music bot with YouTube & Spotify support, featuring bot protection bypass, multi-client extraction strategies, and container-optimized deployment for Railway/Docker environments.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published