A powerful Discord bot built with Node.js that plays and searches YouTube videos in voice channels with queue support.
- YouTube Search: Search for songs directly by name.
- Queue System: Add multiple songs to a queue.
- Skip Support: Skip the current track to the next one in queue.
- Per-Server Management: Separate queues for different Discord servers.
- Node.js: Ensure you have Node.js 20+ installed.
- Discord Bot Token: Create a bot on the Discord Developer Portal.
- Enable Message Content Intent, Server Members Intent, and Presence Intent in the "Bot" section.
- Give the bot permissions to join and speak in voice channels.
- Clone this repository.
- Install dependencies:
npm install
- Copy
.env.exampleto.env:cp .env.example .env
- Fill in your
DISCORD_TOKENand optionally aDEFAULT_VOLUME(between0.0and1.0, where0.1is 10%) in the.envfile.
- Run the bot:
node index.js
- In Discord, join a voice channel.
- Use the following commands:
!play <URL or Search Terms>: Searches and plays the audio. Adds to queue if something is already playing.!skip: Skips the current song.!queue: Shows the current list of songs in the queue.!stop: Stops playback and clears the queue.!leave: Makes the bot leave the voice channel.
discord.js: To interact with the Discord API.@discordjs/voice: For voice channel support.play-dl: To fetch, search, and stream YouTube audio.dotenv: To manage environment variables.