Skip to content

Installation

DisTube depends on a few system tools and a few packages. This page lists everything, and the order to install them in.

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
Terminal window
# Bun (recommended)
bun add @kattowo/distube @discordjs/voice @discordjs/opus
# npm
npm install @kattowo/distube @discordjs/voice @discordjs/opus
# pnpm
pnpm add @kattowo/distube @discordjs/voice @discordjs/opus
# Yarn
yarn add @kattowo/distube @discordjs/voice @discordjs/opus

DisTube uses FFmpeg to process the audio. It has to be installed on your system and available in your PATH.

Terminal window
# Linux (Debian / Ubuntu)
sudo apt-get install ffmpeg
# macOS
brew install ffmpeg
# Windows
winget install Gyan.FFmpeg

If the links above are not available, you can download a static build from FFmpeg-Builds.

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:

Terminal window
bun add @noble/ciphers
# or
bun add sodium-native

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);

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.