SearchResult
The result of a search.
It is the result type of every search, at the plugin level and at the DisTube level.
Type Parameters
Section titled “Type Parameters”T = unknown
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SearchResult<T>(query, options?): SearchResult<T>;Create a search result.
Parameters
Section titled “Parameters”string
The query of the search
options?
Section titled “options?”Optional data
playlist?
Section titled “playlist?”Playlist<T>
The playlist that was found
queryType?
Section titled “queryType?”The kind of result that was looked for
songs?
Section titled “songs?”Song<T>[] = []
The songs that were found
sources?
Section titled “sources?”string[] = []
The identifiers of the plugins that contributed to the result
Returns
Section titled “Returns”SearchResult<T>
Example
Section titled “Example”const result = new SearchResult("Never gonna give you up", { songs: [song] });Properties
Section titled “Properties”playlist?
Section titled “playlist?”readonly playlist?: Playlist<T>;The playlist that was found, when the search returned one.
readonly query: string;The query of the search.
queryType
Section titled “queryType”readonly queryType: SearchResultType;The kind of result that was looked for.
readonly songs: Song<T>[];The songs that were found.
sources
Section titled “sources”readonly sources: string[];The identifiers of the plugins that contributed to the result.
Methods
Section titled “Methods”hasPlaylist()
Section titled “hasPlaylist()”hasPlaylist(): boolean;Whether the search returned a playlist.
Returns
Section titled “Returns”boolean
true when the result has a playlist
hasSongs()
Section titled “hasSongs()”hasSongs(): boolean;Whether the search returned songs.
Returns
Section titled “Returns”boolean
true when the result has at least one song
isEmpty()
Section titled “isEmpty()”isEmpty(): boolean;Whether the search returned nothing.
Returns
Section titled “Returns”boolean
true when the result has neither songs nor a playlist
toJSON()
Section titled “toJSON()”toJSON(): object;A plain object representation of the result.
Returns
Section titled “Returns”object
The plain object representation of the result