A modern Discord music bot with YouTube, Spotify, SoundCloud support (theoretically).
- β Bot comes online on Discord
- β
Responds to
/ping,/helpcommands - β Joins Voice Channel successfully
- β Adds songs to queue (displays embed)
- β Cannot play audio - YouTube has blocked most free libraries
| 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.
| Solution | Difficulty | Stability |
|---|---|---|
| Lavalink + Java | βββ Hard | β 100% stable |
| Use existing bots (Chip, Hydra) | β Easy | β 100% stable |
| Wait for library updates | - | β Unknown |
- πΆ 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
| 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 |
- Go to Discord Developer Portal
- Click "New Application" β Name your bot
- Go to "Bot" tab β Click "Add Bot"
- Copy Token (keep it secret!)
- Enable Privileged Gateway Intents:
PRESENCE INTENTSERVER MEMBERS INTENTMESSAGE CONTENT INTENT
- Go to "OAuth2" β "URL Generator":
- Scopes:
bot,applications.commands - Bot Permissions:
Administrator
- Scopes:
- Copy URL and invite bot to server
# 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- Create account at Railway
- Click "New Project" β "Deploy from GitHub repo"
- Select
discord-botrepository - Add environment variables:
DISCORD_TOKEN,CLIENT_ID - Auto deploy! π
| Variable | Description | Required |
|---|---|---|
DISCORD_TOKEN |
Discord Bot Token | β |
CLIENT_ID |
Bot Client ID | β |
PORT |
Health check port | β (default: 3000) |
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
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!
MIT License - Free to use and modify!
Made with β€οΈ by tungcorn