Advanced Discord v14.22 Music Bot with YouTube, Spotify, SoundCloud, and Direct Link support.
Advanced Discord v14.22 Music Bot with YouTube, Spotify, SoundCloud, and Direct Link support.
/play, /search, /language, /nowplaying, and /help respond instantly with localized embeds and live-updating buttons.…ℹ️
ffmpeg-staticships with the project. You do not need a system-wide FFmpeg unless you prefer using a custom build.
# Run from the repo root
.\setup.bat
# Edit the generated .env with your credentials
.\start.batsetup.bat verifies Node.js/npm, installs dependencies, and scaffolds a .env template if you don’t have one yet. start.bat makes sure your environment is ready and launches the bot via npm run start.
# 1. Clone & enter
git clone https://github.com/umutxyp/musicbot.git discord-musicbot
cd discord-musicbot
# 2. Install dependencies
npm install
# 3. Configure secrets (see below)
Copy-Item .env .env.backup -ErrorAction SilentlyContinue
# Edit .env with your token, client ID, Spotify credentials, etc.
# 4. Boot the bot
npm run start
# or
node index.jsSlash commands register automatically when the bot starts. Guild-scoped deployment executes within seconds if GUILD_ID is provided; global rollout can take up to an hour per Discord caching rules.
Beatra reads from both config.js defaults and environment variables via .env. Update whichever approach fits your hosting workflow.
.env Cheat SheetDISCORD_TOKEN=your_bot_token
CLIENT_ID=your_application_id
GUILD_ID=optional_guild_for_fast_testing
SPOTIFY_CLIENT_ID=spotify_client_id
SPOTIFY_CLIENT_SECRET=spotify_client_secret
GENIUS_CLIENT_ID=optional_genius_client_id
GENIUS_CLIENT_SECRET=optional_genius_client_secret
STATUS= Beatra | /play
EMBED_COLOR=#FF6B6B
SUPPORT_SERVER=https://discord.gg/ACJQzJuckW
WEBSITE=https://beatra.app
COOKIES_FROM_BROWSER=chrome
COOKIES_FILE=./cookies.txt| Setting | Location | Purpose |
|---|---|---|
discord.token |
.env → config.discord.token |
Discord bot token used for login and REST registration. |
discord.clientId |
.env → config.discord.clientId |
Application ID required to register slash commands. |
discord.guildId |
.env → config.discord.guildId |
Optional testing guild ID for Never commit .env to source control. Use deployment secrets in your hosting provider or create environment variables at runtime. |
Beatra Bot) and enable Web API.https://localhost/callback) – although client credentials flow is used, Spotify requires at least one placeholder..env (SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET).Without these credentials Spotify requests fall back to zero results.
Beatra uses web scraping by default to fetch lyrics from Genius—no API key required! However, if you want higher rate limits and faster responses, you can optionally add Genius API credentials.
| Without API Key | With API Key |
|---|---|
| ✅ Works perfectly via web scraping | ✅ Higher rate limits |
| ✅ No registration needed | ✅ Faster response times |
| ⚠️ May hit rate limits on heavy use | ✅ Official API support |
Beatra Bot (or any name)https://localhost (placeholder is fine)https://localhost/callback (not used, but required).env:GENIUS_CLIENT_ID=your_genius_client_id
GENIUS_CLIENT_SECRET=your_genius_client_secretNote: Even without credentials, lyrics work perfectly! The bot automatically scrapes Genius.com and falls back to LRCLIB if needed.
The bot fetches lyrics in this order:
YouTube may occasionally block yt-dlp with a "Sign in to confirm you're not a bot" error. To fix this, you need to provide browser cookies to yt-dlp.
Open your .env file or set environment variables
Add one of the following based on your browser:
# For Chrome users
COOKIES_FROM_BROWSER=chrome
# For Firefox users
COOKIES_FROM_BROWSER=firefox
# For Edge users
COOKIES_FROM_BROWSER=edge
# For Safari users
COOKIES_FROM_BROWSER=safariMake sure you're logged into YouTube in that browser
Restart your bot
Note: This method automatically extracts cookies from your browser, so you need to be logged into YouTube in the specified browser.
Install a browser extension to export cookies:
Go to YouTube while logged in and export cookies to a file named cookies.txt
Place cookies.txt in your bot's root directory (same folder as index.js)
Add to your .env file:
COOKIES_FILE=./cookies.txtRestart your bot
After setting up cookies, test with:
npm startIf you still see bot detection errors:
Security Note: Keep your cookies.txt file private and never share it, as it contains your YouTube session data.
When your bot reaches 1,000+ servers, Discord requires you to use sharding to distribute the load across multiple processes. Beatra includes a fully automated sharding system powered by Discord.js's ShardingManager.
Read the complete Sharding Guide for detailed documentation, troubleshooting, and best practices.
Sharding splits your bot into multiple instances (shards), each handling a subset of servers:
Discord automatically routes events to the correct shard based on server ID.
.\start.batChoose option [2] Sharding Mode when prompted.
.\start-shard.bat
# or
node shard.js| /search | Presents a paginated selection menu of YouTube matches — choose with buttons. |
| /nowplaying | Drops the live embed again, including queue status, repeat/shuffle flags, and volume. |
| /language | Opens a flag button wall for instant localization (cached per guild). |
| /help | Gorgeous, localized feature tour + live stats and support links. |
All button sessions carry a short-lived signature, preventing stale interactions from previous queues.
Beatra features an intelligent autoplay engine that keeps the music flowing when your queue runs out.
The autoplay system includes sophisticated filters to ensure you only get actual music:
Duration Limits:
Keyword Blocking: Automatically skips content containing:
Quality Checks:
No open issues yet, or sync has not completed.