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.js for Discord integration
  • @discordjs/voice for voice playback
  • yt-dlp to stream YouTube audio
  • ffmpeg for 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

  1. 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.
  2. The bot uses yt-dlp to stream raw audio from YouTube and pipes it through ffmpeg to Discord.

  3. Commands like /skip, /loop, /pause, and /volume manipulate the current playback or queue.

  4. If looping is enabled via /loop, the same song repeats when it ends.

  5. The bot automatically leaves the voice channel when playback ends and the queue is empty.


Requirements

Dependencies

Node.js packages

  • discord.js — Discord API wrapper
  • yt-dlp-exec - Node wrapper for yt-dlp
  • @discordjs/voice — Voice connections and audio playback
  • @snazzah/davey — Discord implementation for Node environments
  • dotenv — Load environment variables from .env file
  • ffmpeg-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 PATH
  • ffmpeg — Multimedia framework for audio conversion (optional if using ffmpeg-static, but recommended to have a system installation)

Installation

  1. Clone this repository:
   git clone https://github.com/ez4encelol/Discord-Beat-Bop.git
   cd Discord-Beat-Bop
  1. Install Node.js dependencies: bash npm install
  2. 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
  3. 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

Built With

Share this project:

Updates