TrackUtils
Table of Contentsโ
Class Definitionโ
export abstract class TrackUtils {}
TrackUtils is an abstract utility class. All members are static โ it cannot be instantiated directly.
Propertiesโ
Property Type Description trackPartialTrackPartial[]| nullThe list of track properties to retain. nullmeans all properties are kept.
Methodsโ
build()โ
static build<T = AnyUser>(data: TrackData, requester?: T, isAutoplay?: boolean): TrackBuilds a
Trackobject from raw Lavalink track data.Parametersโ
Parameter Type Description Optional dataTrackDataThe raw encoded track data from Lavalink. requesterT The user who requested the track. isAutoplayboolean Whether the track was queued by autoplay. Defaults to false.Returnsโ
Type Description TrackThe built track object.
init()โ
static init(manager: Manager): voidInitializes the static
Managerreference used byTrackUtils. Called internally by the manager.Parametersโ
Parameter Type Description Optional managerManagerThe Manager instance.
isErrorOrEmptySearchResult()โ
static isErrorOrEmptySearchResult(result: SearchResult): result is ErrorOrEmptySearchResultType guard that returns
trueif the search result has a load type ofEmptyorError.Parametersโ
Parameter Type Description Optional resultSearchResultThe search result to check. Returnsโ
Type Description boolean trueif the result is empty or an error.
isTrack()โ
static isTrack(track: unknown): track is TrackType guard that checks whether the given value is a valid
Trackobject (hastrack,title, andurias strings).Parametersโ
Parameter Type Description Optional trackunknown The value to check. Returnsโ
Type Description boolean trueif the value is a validTrack.
isTrackArray()โ
static isTrackArray(value: unknown): value is Track[]Type guard that checks whether the given value is an array where every element is a valid
Track.Parametersโ
Parameter Type Description Optional valueunknown The value to check. Returnsโ
Type Description boolean trueif the value is aTrack[].
revive()โ
static revive(track: Track): TrackRe-attaches the
displayThumbnailmethod to a deserialized track (e.g. after loading from storage).Parametersโ
Parameter Type Description Optional trackTrackThe track to revive. Returnsโ
Type Description TrackThe revived track.
setTrackPartial()โ
static setTrackPartial(partial: TrackPartial[]): voidSets which track properties are kept when building tracks. Any properties not in the list are deleted from the built object. The
trackproperty is always preserved.Parametersโ
Parameter Type Description Optional partialTrackPartial[]The array of property names to retain on built tracks.
validate()โ
static validate(value: unknown): value is Track | Track[]Returns
trueif the given value is a validTrackor a validTrack[].Parametersโ
Parameter Type Description Optional valueunknown The track or array of tracks to validate. Returnsโ
Type Description boolean trueif the value is a validTrackorTrack[].