A feature-rich Discord music bot built with Discord.js v14 and Lavalink, supporting both slash commands and prefix commands with interactive buttons.
- 🎵 High-quality music playback using Lavalink
- 🎛️ Interactive controls with Discord v2 components (buttons)
- ⚡ Dual command support - Both slash commands (/) and prefix commands (!)
- 🔄 Loop modes - Track, Queue, or Off
- 🔀 Queue management - Shuffle, skip, stop, pause/resume
- 📋 Queue display with pagination
- 🔊 Volume control (1-100%)
- 🎯 Multiple music sources - YouTube, Spotify, SoundCloud, and more
- 📱 Clean, modern embeds with progress bars and track information
- 🛡️ Permission checks and error handling
- ⏱️ Command cooldowns to prevent spam
- YouTube & YouTube Music
- Spotify (track links)
- SoundCloud
- Direct audio URLs
- Search queries
/play <query>- Play a song or playlist/pause- Pause or resume the current song/skip- Skip the current song/stop- Stop music and clear queue/nowplaying- Show current song information/queue [page]- Display the music queue/volume [level]- Set or check volume (1-100)/loop <mode>- Set loop mode (off/track/queue)/shuffle- Shuffle the queue/help- Show all commands
!play <query>- Play a song or playlist!pause- Pause or resume the current song!skip- Skip the current song!stop- Stop music and clear queue!np- Show current song information!queue [page]- Display the music queue!volume [level]- Set or check volume (1-100)!loop [mode]- Set loop mode (off/track/queue)!shuffle- Shuffle the queue!help- Show all commands
Use the buttons below music messages for quick controls:
- ⏸️ Pause/Resume
- ⏭️ Skip
- ⏹️ Stop
- 🔀 Shuffle
- 🔁 Loop
- Node.js (v16.9.0 or higher)
- Lavalink Server (v3.7 or higher)
- Discord Bot Token
-
Clone the repository
git clone https://github.com/friday2su/lavalink-music-bot.git cd lavalink-music-bot -
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env
Edit
.envfile with your configuration:# Discord Bot Configuration DISCORD_TOKEN=your_discord_bot_token_here CLIENT_ID=your_bot_client_id_here # Bot Configuration PREFIX=! OWNER_ID=your_discord_user_id_here # Lavalink Configuration LAVALINK_HOST=localhost LAVALINK_PORT=2333 LAVALINK_PASSWORD=youshallnotpass LAVALINK_SECURE=false
-
Set up Lavalink Server
Download Lavalink from GitHub Releases
Create
application.yml:server: port: 2333 address: 0.0.0.0 lavalink: server: password: "youshallnotpass" sources: youtube: true bandcamp: true soundcloud: true twitch: true vimeo: true http: true local: false bufferDurationMs: 400 frameBufferDurationMs: 5000 youtubePlaylistLoadLimit: 6 playerUpdateInterval: 5 youtubeSearchEnabled: true soundcloudSearchEnabled: true gc-warnings: true
-
Start Lavalink
java -jar Lavalink.jar
-
Deploy slash commands (optional)
npm run deploy
Or directly:
node src/index.js --deploy
This manually registers slash commands globally. The bot will also auto-register commands when it starts.
-
Start the bot
npm start
The bot requires the following permissions:
Send MessagesUse Slash CommandsEmbed LinksConnect(to voice channels)Speak(in voice channels)Use Voice Activity
src/
├── commands/
│ ├── slash/ # Slash commands
│ └── prefix/ # Prefix commands
├── events/ # Discord.js events
├── utils/ # Utility functions
└── index.js # Main bot file
| Variable | Description | Required |
|---|---|---|
DISCORD_TOKEN |
Your Discord bot token | Yes |
CLIENT_ID |
Your bot's client ID | Yes |
PREFIX |
Command prefix (default: !) | No |
OWNER_ID |
Bot owner's Discord user ID | No |
LAVALINK_HOST |
Lavalink server host | Yes |
LAVALINK_PORT |
Lavalink server port | Yes |
LAVALINK_PASSWORD |
Lavalink server password | Yes |
LAVALINK_SECURE |
Use secure connection (wss) | No |
Make sure your Lavalink server is properly configured with the sources you want to use. The bot supports all sources that Lavalink supports.
-
Bot doesn't respond to commands
- Check if the bot has proper permissions
- Verify the bot token is correct
- Ensure the bot is online
-
Music doesn't play
- Check if Lavalink server is running
- Verify Lavalink connection settings
- Ensure the bot has voice permissions
-
Slash commands not showing
- Wait up to 1 hour for global commands to update
- Check if the bot has
Use Slash Commandspermission - Restart the bot if commands were recently added
If you encounter any issues:
- Check the console for error messages
- Verify all configuration settings
- Ensure all dependencies are installed
- Check Discord and Lavalink server status
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Discord.js - Discord API library
- Lavalink - Audio delivery node
- Kazagumo - Lavalink wrapper
- Shoukaku - Lavalink connector