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[].