Installation
DisTube depends on a few system tools and a few packages. This page lists everything, and the order to install them in.
Requirements
Section titled “Requirements”| Requirement | Version |
|---|---|
| Node.js | 22.12.0 or higher |
| discord.js | v14 |
| @discordjs/voice | >=0.19.1 |
| @discordjs/opus | ^0.10.0 |
| FFmpeg | any recent version |
1. Install the packages
Section titled “1. Install the packages”# Bun (recommended)bun add @kattowo/distube @discordjs/voice @discordjs/opus
# npmnpm install @kattowo/distube @discordjs/voice @discordjs/opus
# pnpmpnpm add @kattowo/distube @discordjs/voice @discordjs/opus
# Yarnyarn add @kattowo/distube @discordjs/voice @discordjs/opus2. Install FFmpeg
Section titled “2. Install FFmpeg”DisTube uses FFmpeg to process the audio. It has to be installed on your system and available in
your PATH.
# Linux (Debian / Ubuntu)sudo apt-get install ffmpeg
# macOSbrew install ffmpeg
# Windowswinget install Gyan.FFmpegIf the links above are not available, you can download a static build from FFmpeg-Builds.
3. Install an encryption library
Section titled “3. Install an encryption library”Discord.js needs an encryption library to talk to the voice servers. DisTube works with any library
supported by @discordjs/voice.
Check whether your runtime supports aes-256-gcm natively:
require("node:crypto").getCiphers().includes("aes-256-gcm");If it returns false, install one of these:
bun add @noble/ciphers# orbun add sodium-native4. Create the client
Section titled “4. Create the client”DisTube needs the GuildVoiceStates intent. The Guilds intent is required by discord.js itself.
import { Client, GatewayIntentBits } from "discord.js";import { DisTube } from "@kattowo/distube";
const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ],});
const distube = new DisTube(client);5. Add a music source
Section titled “5. Add a music source”DisTube ships no music source. Every service is a plugin, and the plugins live outside the library.
import { DisTube, ExtractorPlugin } from "@kattowo/distube";
class MyExtractor extends ExtractorPlugin { override readonly source = "my-source";
async validate(url) { return url.startsWith("https://audio.example.com/"); }
async resolve(url, options) { // Return a Song or a Playlist. }
async getStreamURL(song) { return song.url; }}
const distube = new DisTube(client, { plugins: [new MyExtractor()],});The plugin system guide has the whole API of a plugin.
- Quick start — build the commands
- Plugin system — add the music sources