Skip to content

DisTubeHandler

DisTube’s Handler

new DisTubeHandler(distube): DisTubeHandler;

Create a new base object.

DisTube

The DisTube instance

DisTubeHandler

DisTubeBase.constructor

distube: DisTube;

The DisTube instance this object belongs to.

DisTubeBase.distube

get client(): Client;

Discord.js client

Client

DisTubeBase.client


get handler(): DisTubeHandler;

DisTube handler

DisTubeHandler

DisTubeBase.handler


get options(): Options;

DisTube options

Options

DisTubeBase.options


get plugins(): DisTubePlugin[];

DisTube plugins

DisTubePlugin[]

DisTubeBase.plugins


get queues(): QueueManager;

The queue manager

QueueManager

DisTubeBase.queues


get voices(): DisTubeVoiceManager;

The voice manager

DisTubeVoiceManager

DisTubeBase.voices

_getPluginFromSong(song): Promise<
| DisTubePlugin
| null>;

Find the plugin that can handle the given song.

Song

The song

Promise< | DisTubePlugin | null>

The plugin, or null when there is none

_getPluginFromSong<T>(
song,
types,
validate?
): Promise<DisTubePlugin & { type: T; } | null>;

Find the plugin of the given type that can handle the given song.

T extends PluginType

Song

The song

T[]

The types of the plugin to look for

boolean

Whether the url of the song has to be validated

Promise<DisTubePlugin & { type: T; } | null>

The plugin, or null when there is none


_getPluginFromURL(url): Promise<
| DisTubePlugin
| null>;

Find the plugin that supports the given url.

string

The url to check

Promise< | DisTubePlugin | null>

The plugin, or null when there is none


attachStreamInfo(song): Promise<void>;

Get Song’s stream info and attach it to the song.

Song

A Song

Promise<void>

A promise that resolves when the stream info is attached

DisTubeError When no plugin supports the song, or when its stream URL cannot be found


debug(message): void;

Emit debug event

string

debug message

void

Nothing

DisTubeBase.debug


emit(eventName, ...args): boolean;

Emit the DisTube of this base

keyof DisTubeEvents

Event name

…any

arguments

boolean

true when the event had listeners, false otherwise

DisTubeBase.emit


emitError(
error,
queue,
song?
): void;

Emit error event

Error

error

Queue

The queue encountered the error

Song<unknown>

The playing song when encountered the error

void

Nothing

DisTubeBase.emitError


followRedirectLink(url, maxRedirect?): Promise<string>;

Follow the redirections of an url.

string

The url to follow

number = MAX_REDIRECT_DEPTH

The maximum number of redirections to follow

Promise<string>

The final url


Resolve a url or a supported object to a Song or Playlist

DisTubeError

input

Resolvable input

options

Optional options

resolve<T>(song, options?): Promise<Song<T>>;

Resolve a Song to a Song.

T = unknown

Song<T>

The song to resolve

Omit<ResolveOptions<unknown>, "metadata">

Optional options

Promise<Song<T>>

The resolved song

resolve<T>(song, options?): Promise<Playlist<T>>;

Resolve a Playlist to a Playlist.

T = unknown

Playlist<T>

The playlist to resolve

Omit<ResolveOptions<unknown>, "metadata">

Optional options

Promise<Playlist<T>>

The resolved playlist

resolve<T>(song, options?): Promise<
| Song<T>
| Playlist<T>>;

Resolve a url or a search query to a Song or a Playlist.

T = unknown

string

The url or the search query to resolve

ResolveOptions<T>

Optional options

Promise< | Song<T> | Playlist<T>>

The resolved song or playlist

resolve<T>(song, options): Promise<Song<T>>;

Resolve a Song to a Song.

T = unknown

Song

The song to resolve

ResolveOptions<T>

Optional options

Promise<Song<T>>

The resolved song

resolve<T>(song, options): Promise<Playlist<T>>;

Resolve a Playlist to a Playlist.

T = unknown

Playlist

The playlist to resolve

ResolveOptions<T>

Optional options

Promise<Playlist<T>>

The resolved playlist

resolve(song, options?): Promise<
| Song<unknown>
| Playlist<unknown>>;

Resolve a url or a supported object to a Song or Playlist

| string | Song<unknown> | Playlist<unknown>

Resolvable input

ResolveOptions<unknown>

Optional options

Promise< | Song<unknown> | Playlist<unknown>>

Resolved

DisTubeError

const song = await distube.handler.resolve("Never gonna give you up");