Star ✨ on GitHub

Track

Represents a single audio track, containing metadata like title, author, duration, and the encoded string required by Lavalink.

The Track class wraps the raw data received from Lavalink into a usable object. It provides helper methods for thumbnails, cloning, and serialization.

Properties

Track Fields

Metadata and state for the audio track.

Core Data

encodedstring

The base64 encoded string from Lavalink. This is what you send to the node to play the song.

identifierstring

The unique identifier of the track (e.g., YouTube Video ID).

titlestring

The title of the track.

authorstring

The artist or channel name.

durationnumber

The length of the track in milliseconds.

uristring | null

The original URL of the track.

State & Extra

positionnumber

The starting position of the track (usually 0).

isStreamboolean

Whether the track is a live stream.

isSeekableboolean

Whether the track supports seeking.

sourceNamestring

The source platform (e.g., youtube, spotify, soundcloud).

artworkUrlstring | null

The URL of the album art or thumbnail provided by the source.

requesterunknown

The user or object that requested this track.

Getters

thumbnail

Returns the artwork URL if available. If not, and the source is YouTube, it automatically generates the mqdefault thumbnail URL based on the identifier.

Example
const thumb = track.thumbnail;

Methods

setRequester(requester)

Sets the requester for the track. This is useful for displaying who added the song.

requesterany required

The user or object to set as requester.

Example
track.setRequester(message.author);

setPosition(position)

Sets the starting position of the track. This does NOT seek the active player; it only modifies the track object's metadata for when it is eventually played.

positionnumber required

Position in milliseconds.

Example
track.setPosition(30000); // Start at 30s

clone()

clone()#

Creates a deep copy of the current track.

Example
const newTrack = track.clone();

isPartialTrack()

Returns true if the track was created with partial data loading enabled in the Manager options.

Example
if (track.isPartialTrack()) {
    console.log("This track has incomplete metadata.");
}

toJSON()

toJSON()#

Converts the Track object back into the raw JSON format expected by Lavalink or for storage.

Example
const rawData = track.toJSON();