Track
A Discord-library-agnostic track model. Source resolution belongs to a source plugin.
class Track<Metadata = unknown> implements Serializable<SerializedTrack>A Discord-library-agnostic track model. Source resolution belongs to a source plugin.
Constructors
constructor
constructor<Metadata = unknown>(player: LegacyPlayerContext, data: TrackData<Metadata>)Legacy construction; Player is not needed by modern source plugins.
Parameters
| Name | Type | Description |
|---|---|---|
| player | LegacyPlayerContext | Owning legacy Player. |
| data | TrackData<Metadata> | Legacy metadata and local engine payload. |
constructor<Metadata = unknown>(data?: TrackData<Metadata>)Create a modern data-only track.
Parameters
| Name | Type | Description |
|---|---|---|
| data? | TrackData<Metadata> | Track metadata and portable provider identity. |
Properties
idreadonly
readonly id: stringStable identifier for this Track instance.
title
title: stringDisplay title.
description
description: stringTrack description.
url
url: stringSource page URL.
thumbnail
thumbnail: stringThumbnail URL.
duration
duration: stringHuman-readable duration.
views
views: numberView or play count when available.
requestedBy
requestedBy: TrackRequester | nullUser or application identity that requested this track.
source
source: stringProvider-defined source name or identifier.
live
live: booleanWhether this is a live stream without a fixed duration.
playlist
playlist: Playlist | nullPlaylist containing this track, when present.
sourceReferenceoptional
sourceReference?: ProviderReferencePortable source identity used by the plugin host.
lyricsReferenceoptional
lyricsReference?: ProviderReferenceOptional portable lyrics provider affinity.
sourceStateoptional
sourceState?: stringOpaque, expiring host state hint. Excluded from toJSON() and serialize(); retain only in memory.
rawreadonly
readonly raw: Record<string, any>Process-local v7 raw payload. Never serialized.
queryTypeoptional
queryType?: stringLegacy query hint.
cleanTitle
cleanTitle: stringLegacy display title.
playerreadonlyoptional
readonly player?: LegacyPlayerContextLegacy owning Player, absent for modern data-only tracks.
bridgedExtractor
bridgedExtractor: BaseExtractor<any> | nullProcess-local v7 bridge provider; never used by core queue playback.
bridgedTrack
bridgedTrack: Track<unknown> | nullProcess-local v7 bridge metadata; never persisted.
Accessors
extractor
get extractor(): BaseExtractor<any> | nullCompatibility extractor reference. Assigning it stamps a portable provider identity.
Returns
BaseExtractor<any> | null
set extractor(value: BaseExtractor<any> | null)requester
get requester(): TrackRequester | nullAlias for the v7 requestedBy field.
Returns
TrackRequester | null
set requester(value: TrackRequester | null)metadata
get metadata(): Metadata | nullArbitrary source-plugin metadata.
Returns
Metadata | null
set metadata(value: Metadata | null)hasMetadatareadonly
readonly get hasMetadata(): booleanWhether source-plugin metadata is present.
Returns
boolean
durationMSreadonly
readonly get durationMS(): numberTrack duration in milliseconds, parsed from duration when not supplied.
Returns
number
Methods
requestMetadata
requestMetadata(): Promise<Metadata | null>Request legacy metadata; the callback remains process-local.
Returns
Promise<Metadata | null>
setMetadata
setMetadata(value: Metadata | null): voidReplace legacy metadata.
Parameters
| Name | Type | Description |
|---|---|---|
| value | Metadata | null | New metadata. |
Returns
void
asMetadata
asMetadata<NewMetadata>(): Track<NewMetadata>Cast this Track to a different metadata type without copying it.
Returns
Track<NewMetadata>
The same Track reference with a different metadata type.
toString
toString(): stringFormat the Track as title by author, omitting the author when empty.
Returns
string
toHyperlink
toHyperlink(): stringFormat the Track title as a Markdown hyperlink to its source URL.
Returns
string
toJSON
toJSON(hidePlaylist: boolean = false): TrackJSON<Metadata>Return a JSON-compatible Track representation.
Parameters
| Name | Type | Description |
|---|---|---|
| hidePlaylist | booleanDefault: false | When true, omit playlist metadata to prevent nested playlist serialization. |
Returns
TrackJSON<Metadata>
serialize
Implementation of Serializable.serialize
serialize(): SerializedTrackSerialize public Track data using schema version 1. Requesters are reduced to their string identity, Playlist links are omitted, and metadata must be JSON-safe.
Returns
SerializedTrack
A versioned Track persistence payload.
Static methods
deserializestatic
Construct a Track from public model data without resolving its media source.
Parameters
| Name | Type | Description |
|---|---|---|
| data | TrackData<Metadata> | Track fields and optional source-plugin metadata. |
Returns
Track<Metadata>
A Track instance reconstructed from the provided fields.
fromSerializedstatic
static fromSerialized(serialized: SerializedTrack): TrackReconstruct a Track from a validated versioned persistence payload.
Parameters
| Name | Type | Description |
|---|---|---|
| serialized | SerializedTrack | Versioned Track payload. |
Returns
Track
A Track instance with no reconstructed source-plugin playback state.