Discord Youtube Bot
Overview
This Discord bot allows users to play YouTube audio, manage a music queue, adjust volume, loop songs, and control playback directly from a voice channel using text commands.
It uses:
discord.jsfor Discord integration@discordjs/voicefor voice playbackyt-dlpto stream YouTube audioffmpegfor audio processing
Features
- Stream YouTube audio directly into voice channels
- Maintain a queue of songs per server
- Loop the current track
- Pause/resume playback
- Skip current track
- Control volume
- Stop and disconnect from voice
- Clear the music queue
Commands
All commands start with
/
| Command | Description | Options |
|---|---|---|
/play |
Play a YouTube video by URL | url (string, required) |
/skip |
Skip the currently playing track | None |
/loop |
Toggle loop mode (repeat current song) | None |
/pause |
Pause playback | None |
/resume |
Resume playback | None |
/stop |
Stop playback and leave voice channel | None |
/volume |
Set playback volume | level (integer, required) |
/queue |
Show the current music queue | None |
/clear |
Clear the current music queue | None |
How It Works
When a user types
/play <YouTube URL>in a text channel:- If nothing is playing, the bot joins the user's voice channel and plays the audio.
- If something is already playing, it adds the song to the queue.
The bot uses
yt-dlpto stream raw audio from YouTube and pipes it throughffmpegto Discord.Commands like
/skip,/loop,/pause, and/volumemanipulate the current playback or queue.If looping is enabled via
/loop, the same song repeats when it ends.The bot automatically leaves the voice channel when playback ends and the queue is empty.
Requirements
- Node.js v18 or higher
- Node.js Dependencies and External programs below
- Discord bot token and application registered on the Discord Developer Portal
Dependencies
Node.js packages
discord.js— Discord API wrapperyt-dlp-exec- Node wrapper for yt-dlp@discordjs/voice— Voice connections and audio playback@snazzah/davey— Discord implementation for Node environmentsdotenv— Load environment variables from.envfileffmpeg-static— Static ffmpeg binary for audio transcoding- Built-in Node.js modules:
child_process
External Programs (must be installed on your system)
yt-dlp— YouTube video/audio downloader, installed and accessible in your system PATHffmpeg— Multimedia framework for audio conversion (optional if usingffmpeg-static, but recommended to have a system installation)
Installation
- Clone this repository:
git clone https://github.com/ez4encelol/Discord-Beat-Bop.git
cd Discord-Beat-Bop
- Install Node.js dependencies:
bash npm install - Inside the src folder, Create an .env file and insert your Discord Bot Token and Discord Client ID:
ini TOKEN = your_discord_bot_token CLIENT_ID = your_discord_client_id - Run the bot from inside the src folder:
bash cd src node index.js---
To-do list
Implement:
- Playlists
- Spotify links
- Web UI for queue management
Log in or sign up for Devpost to join the conversation.