Skip to content

Audio playback for Discord bots.

Multi-source playback, audio crossfade, live audio filters, autoplay, and plugin extractors with complete TypeScript types.

npm install @kattowo/distube @discordjs/voice @discordjs/opus
queue.status: playing · 48,000 Hz PCM
NOW STREAMING
Late Night Lo-Fi Session
source plugin · 3:24 elapsed · Bitrate 160 kbps
01Late Night Lo-Fi SessionPlaying3:24
02Chillhop Essentials - AutumnQueued2:48

Features

DisTube manages audio streaming and queue operations for discord.js bots.

Multi-source playback

Play audio from the service of your choice. Every service is a plugin, so the core ships none of them and the install stays small.

Live audio filters

Apply fifteen built-in audio filters while tracks play, on a per-guild basis. Change nightcore, 3D audio, and bass boost without restarting the stream.

NightcoreBass boost3D audioKaraoke

Autoplay

When a queue finishes, DisTube fetches related tracks from the source plugin to keep playback going without manual intervention.

Plugin system

Write custom audio extractors in a few lines of code. Plugins can search, validate links, resolve streams, or pass unplayable tracks to other handlers.

TypeScript definitions

Every option, event listener, and error code is typed. Editors provide autocomplete for queue states, song metadata, and plugin options.

Event-based error handling

Errors emit as standard events rather than unhandled process exceptions. A missing error listener will not crash your Discord bot.

A Discord bot in twenty lines

Initialize DisTube with your discord.js client and handle message commands.

import { DisTube, Events } from "@kattowo/distube";
import { Client, GatewayIntentBits } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
const distube = new DisTube(client);
distube.on(Events.PLAY_SONG, (queue, song) => {
queue.textChannel.send(`Playing: ${song.name} (${song.formattedDuration})`);
});
client.on("messageCreate", async (message) => {
if (!message.content.startsWith("!play")) return;
const query = message.content.slice(6).trim();
if (!query) return;
await distube.play(message.member.voice.channel, query, {
message,
member: message.member,
textChannel: message.channel,
});
});
client.login(process.env.DISCORD_TOKEN);

Bring your own source

A plugin knows one service. It resolves the links, searches the tracks, and gives the stream.

import { DisTube, ExtractorPlugin } from "@kattowo/distube";
class MyExtractor extends ExtractorPlugin {
// The identifier of the source. It is what `getPlugin("my-source")` finds.
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()],
});

Documentation guides

Setup requirements, voice configurations, and API documentation.