Skip to content

🎧 Building my own music bot for fun until YouTube API said no. 🫠

Notifications You must be signed in to change notification settings

tungcorn/discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 Discord Music Bot

A modern Discord music bot with YouTube, Spotify, SoundCloud support (theoretically).

Discord.js Node.js License


⚠️ PROJECT STATUS: SUSPENDED

What Works

  • βœ… Bot comes online on Discord
  • βœ… Responds to /ping, /help commands
  • βœ… Joins Voice Channel successfully
  • βœ… Adds songs to queue (displays embed)

What Doesn't Work

  • ❌ Cannot play audio - YouTube has blocked most free libraries

πŸ› οΈ Libraries Attempted

Library Result
discord-player + @discord-player/extractor ❌ ERR_NO_RESULT
discord-player-youtubei ❌ Parser errors, skips all tracks
play-dl ❌ No results found
ffmpeg-static + @discordjs/opus βœ… Installed, but no audio

All attempts failed due to YouTube API changes and blocking of free scraping libraries.


πŸ”§ Possible Solutions (Not Implemented)

Solution Difficulty Stability
Lavalink + Java ⭐⭐⭐ Hard βœ… 100% stable
Use existing bots (Chip, Hydra) ⭐ Easy βœ… 100% stable
Wait for library updates - ❓ Unknown

✨ Features (If Working)

  • 🎢 Play music from YouTube, Spotify
  • πŸ“‹ Smart queue system
  • πŸ”€ Shuffle, Loop, Volume control
  • 🎨 Modern Slash Commands
  • πŸ“Š Progress bar, beautiful Now Playing embed
  • πŸš€ Optimized for Railway (Free Hosting)
  • πŸ”„ Auto-reconnect, Error handling

πŸ“‹ Commands

Command Description
/play <query> Play music from name or URL
/pause Pause music
/resume Resume playback
/stop Stop and clear queue
/skip Skip current track
/queue View queue
/nowplaying View current track
/volume <0-100> Adjust volume
/loop <mode> Loop mode
/shuffle Shuffle queue
/leave Bot leaves voice channel
/ping Check latency
/help View help

πŸ› οΈ Installation

Step 1: Create Discord Bot

  1. Go to Discord Developer Portal
  2. Click "New Application" β†’ Name your bot
  3. Go to "Bot" tab β†’ Click "Add Bot"
  4. Copy Token (keep it secret!)
  5. Enable Privileged Gateway Intents:
    • PRESENCE INTENT
    • SERVER MEMBERS INTENT
    • MESSAGE CONTENT INTENT
  6. Go to "OAuth2" β†’ "URL Generator":
    • Scopes: bot, applications.commands
    • Bot Permissions: Administrator
  7. Copy URL and invite bot to server

Step 2: Local Setup

# Clone repository
git clone https://github.com/tungcorn/discord-bot.git
cd discord-bot

# Install dependencies
npm install

# Create .env file
copy .env.example .env
# Fill in DISCORD_TOKEN and CLIENT_ID

# Register slash commands
npm run deploy

# Run bot
npm start

Step 3: Deploy to Railway (Optional)

  1. Create account at Railway
  2. Click "New Project" β†’ "Deploy from GitHub repo"
  3. Select discord-bot repository
  4. Add environment variables: DISCORD_TOKEN, CLIENT_ID
  5. Auto deploy! πŸŽ‰

πŸ” Environment Variables

Variable Description Required
DISCORD_TOKEN Discord Bot Token βœ…
CLIENT_ID Bot Client ID βœ…
PORT Health check port ❌ (default: 3000)

πŸ“‚ Project Structure

discord-bot/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.js              # Entry point
β”‚   β”œβ”€β”€ deploy-commands.js    # Commands registration
β”‚   β”œβ”€β”€ commands/
β”‚   β”‚   β”œβ”€β”€ music/            # Music commands
β”‚   β”‚   └── utility/          # Utility commands
β”‚   β”œβ”€β”€ events/               # Discord events
β”‚   └── utils/                # Utility functions
β”œβ”€β”€ .env.example
β”œβ”€β”€ package.json
β”œβ”€β”€ railway.json
β”œβ”€β”€ Dockerfile
└── README.md

❓ FAQ

Q: Will this project be updated?
A: Maybe, if free libraries find a workaround for YouTube blocking.

Q: Should I use this code?
A: Only for learning purposes. For production, use Lavalink or existing bots.

Q: Can I contribute?
A: Yes! If you find a working solution, PRs are welcome!

πŸ“„ License

MIT License - Free to use and modify!


Made with ❀️ by tungcorn

About

🎧 Building my own music bot for fun until YouTube API said no. 🫠

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •