Track Object
TheTrack class represents a single audio track.
Track Properties
Creating Tracks
Tracks are typically created automatically through searches:Track Methods
toJSON()
Get JSON representation:toHyperlink()
Get Discord markdown hyperlink:toString()
Get string representation:play()
Play the track directly:Track Metadata
Attach custom metadata to tracks:Serialization
Serialize and deserialize tracks:Track Source
Get the track’s source platform:Getting Track Queue
Find which queue contains a track:Seeking Support
Check and control seek functionality:Audio Resource
Access the underlying audio resource:Playlist Object
ThePlaylist class represents a collection of tracks.
Playlist Properties
Creating Playlists
Playlists are typically created from search results:Playlist Methods
Iteration
Playlists are iterable:Duration
Get total playlist duration:toJSON()
Get JSON representation:play()
Play the entire playlist:Serialization
Serialize and deserialize playlists:Working with Search Results
TheSearchResult object contains tracks and/or playlists:
Track Resolution
Tracks can be resolved in multiple ways:Example: Track Management
Example: Custom Track Source
Best Practices
Clean Track Titles
Clean Track Titles
Use
track.cleanTitle for sanitized titles without special characters:Track Metadata for Context
Track Metadata for Context
Store interaction context in track metadata for later use:
Handling Live Streams
Handling Live Streams
Check if a track is a live stream:
See Also
- Player - Learn about the Player class
- GuildQueue - Queue management
- Events - Track-related events