Skip to content

SearchResult

The result of a search.

It is the result type of every search, at the plugin level and at the DisTube level.

T = unknown

new SearchResult<T>(query, options?): SearchResult<T>;

Create a search result.

string

The query of the search

Optional data

Playlist<T>

The playlist that was found

SearchResultType

The kind of result that was looked for

Song<T>[] = []

The songs that were found

string[] = []

The identifiers of the plugins that contributed to the result

SearchResult<T>

const result = new SearchResult("Never gonna give you up", { songs: [song] });
readonly playlist?: Playlist<T>;

The playlist that was found, when the search returned one.


readonly query: string;

The query of the search.


readonly queryType: SearchResultType;

The kind of result that was looked for.


readonly songs: Song<T>[];

The songs that were found.


readonly sources: string[];

The identifiers of the plugins that contributed to the result.

hasPlaylist(): boolean;

Whether the search returned a playlist.

boolean

true when the result has a playlist


hasSongs(): boolean;

Whether the search returned songs.

boolean

true when the result has at least one song


isEmpty(): boolean;

Whether the search returned nothing.

boolean

true when the result has neither songs nor a playlist


toJSON(): object;

A plain object representation of the result.

object

The plain object representation of the result