Plugin
A media provider, an engine, or both. Data types the pluginData slot of every Song it returns, and ListData
that of every Playlist.
A plugin has name and at least one of resolve, search, stream or engine. Core only passes Songs whose
source is this plugin’s name. A thrown DisTubeError reaches the caller unchanged, except that
INVALID_ARGUMENT, INVALID_STATE and ABORTED without a caller abort become SOURCE_FAILED with the original
as cause. Any other throw becomes SOURCE_FAILED with source set to name.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Data |
unknown |
ListData |
unknown |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
engine? |
Engine |
Replaces the Adapter’s built-in engine. At most one configured plugin carries one. |
name |
string |
- |
Methods
Section titled “Methods”dispose()?
Section titled “dispose()?”
optionaldispose():void|Promise<void>
Returns
Section titled “Returns”void | Promise<void>
related()?
Section titled “related()?”
optionalrelated(song,options):Promise<Song<Data> |undefined>
Autoplay continuation, or undefined to decline.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
song |
Song<Data> |
options |
RelatedOptions |
Returns
Section titled “Returns”Promise<Song<Data> | undefined>
resolve()?
Section titled “resolve()?”
optionalresolve(url,options):Promise<Song<Data> |Playlist<Data,ListData> |undefined>
Resolves a URL the plugin owns, or declines with undefined.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
url |
string |
options |
ResolveOptions |
Returns
Section titled “Returns”Promise<Song<Data> | Playlist<Data, ListData> | undefined>
search()?
Section titled “search()?”
optionalsearch(query,options):Promise<readonlySong<Data>[]>
Provider-ranked results. An empty array declines.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
query |
string |
options |
SearchOptions |
Returns
Section titled “Returns”Promise<readonly Song<Data>[]>
stream()?
Section titled “stream()?”
optionalstream(song,options):Promise<PlaybackResource>
A fresh resource for an owned Song. Without it, and without an engine prepare, core searches every other plugin
that has search and stream for the Song’s name and artist and plays the first candidate that prepares.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
song |
Song<Data> |
options |
{ signal: AbortSignal; } |
options.signal |
AbortSignal |
Returns
Section titled “Returns”Promise<PlaybackResource>
suggest()?
Section titled “suggest()?”
optionalsuggest(query,options):Promise<readonlystring[]>
Completions for a partial query, at most 25 used.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
query |
string |
options |
{ signal: AbortSignal; } |
options.signal |
AbortSignal |
Returns
Section titled “Returns”Promise<readonly string[]>