A feature-rich Discord music bot built with Node.js and Discord.js that supports playing music from YouTube and Spotify links, with advanced autoplay functionality and queue management.
- Multi-Platform Support: Play music from YouTube and Spotify links
- Autoplay: Automatically plays related songs when the queue ends
- Queue Management: Add, skip, and insert songs in the queue
- Smart Search: Intelligent search for related music by artist
- Duration Filtering: Autoplay only plays songs under 6 minutes
- Docker Support: Easy deployment with Docker containers
- Node.js 18.x or higher
- FFmpeg installed on your system
- Discord Bot Token
- YouTube Data API v3 Key (optional, for enhanced autoplay)
- Spotify API Credentials (optional, for Spotify link support)
-
Clone the repository
git clone <repository-url> cd MALAZ-BOTT
-
Install dependencies
npm install
-
Set up environment variables Create a
.envfile in the root directory:DISCORD_TOKEN=your_discord_bot_token_here YOUTUBE_API_KEY=your_youtube_api_key_here SPOTIFY_CLIENT_ID=your_spotify_client_id_here SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here
-
Run the bot
node index.js
-
Build and run with Docker Compose
docker-compose up -d
-
Or build manually
docker build -t malaz-bott . docker run -d --name malaz-bott malaz-bott
| Command | Description | Usage |
|---|---|---|
c!play <url/query> |
Play music from YouTube/Spotify URL or search query | c!play https://youtube.com/watch?v=... |
c!skip |
Skip the current song | c!skip |
c!insert <url/query> |
Insert a song next in the queue | c!insert https://spotify.com/track/... |
c!autoplay |
Toggle autoplay on/off | c!autoplay |
c!help |
Show all available commands | c!help |
- Go to Discord Developer Portal
- Create a new application
- Go to the "Bot" section and create a bot
- Copy the bot token and add it to your
.envfile - Enable the following intents:
- Message Content Intent
- Server Members Intent
- Voice States Intent
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable YouTube Data API v3
- Create credentials (API Key)
- Add the API key to your
.envfile
- Go to Spotify Developer Dashboard
- Create a new app
- Copy the Client ID and Client Secret
- Add them to your
.envfile
- Automatically finds related songs when the queue ends
- Searches by artist name for better relevance
- Filters out duplicate songs and videos longer than 6 minutes
- Falls back to random popular music if no related songs found
- Extracts artist names from song titles
- Uses multiple search strategies for better results
- Handles various title formats (Artist - Song, Artist by Song, etc.)
- Add songs to the end of the queue
- Insert songs next in the queue
- Skip current song
- Automatic queue progression
The bot is configured to run in a Debian-based container for optimal FFmpeg support. The Dockerfile includes:
- Node.js 18 runtime
- FFmpeg installation
- Proper user permissions
- Health checks
MALAZ-BOTT/
├── index.js # Main bot file
├── package.json # Dependencies and scripts
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose setup
├── .env # Environment variables (create this)
├── .gitignore # Git ignore rules
└── README.md # This file
- Never commit your
.envfile to version control - Keep your API keys secure and rotate them regularly
- The bot only requires basic Discord permissions
-
Bot not joining voice channel
- Ensure the bot has "Connect" and "Speak" permissions
- Check that voice intents are enabled
-
No audio output
- Verify FFmpeg is installed on your system
- Check that the bot has proper audio permissions
-
Autoplay not working
- Ensure YouTube API key is configured (optional)
- Check internet connectivity
-
Spotify links not working
- Verify Spotify API credentials are set
- Check that the Spotify app has proper permissions
The bot logs important events to the console. Check the logs for error messages and debugging information.
- 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 wrapper
- @discordjs/voice - Voice functionality
- yt-dlp - YouTube video downloader
- Spotify Web API - Spotify integration
If you encounter any issues or have questions, please:
- Check the troubleshooting section above
- Review the logs for error messages
- Create an issue on the repository
Note: This bot is for educational and personal use. Please respect YouTube's and Spotify's terms of service when using this bot.