Discord Player
API reference

Models

Track, Playlist, SearchResult, and their storage format.

You are reading the v8 docsDev

Track

A Track holds metadata and a sourceReference. It does not hold an open decoder.

import { Track } from 'discord-player';

const track = new Track({
  title: 'Example',
  author: 'Artist',
  url: 'https://media.example.com/track.mp3',
  durationMS: 180_000,
});
FieldDescription
idUnique ID. Generated when omitted
title, author, description, thumbnail, urlDisplay metadata
durationMS, durationDuration in milliseconds, and a formatted label
requestedByWho requested the track. An ID string or an object
sourceProvider-defined source name
livetrue for live streams
playlistThe playlist the track came from, or null
sourceReferencePortable identity of the source plugin and host
lyricsReferencePortable identity of a preferred lyrics provider
extractor, raw, queryTypev7 compatibility fields. Not safe to store

For legacy extractors, new Track(player, data) also works.

Playlist

A Playlist is an ordered list of tracks with title, author, thumbnail, source, URL, and type. You can iterate it:

for (const track of playlist) console.log(track.title);

SearchResult

player.search() returns a SearchResult with tracks, an optional playlist, and helpers such as first() and isEmpty(). A string that no plugin matches gives an empty result. It does not throw.

Storage

import { decode, deserialize, encode, serialize } from 'discord-player';

const text = encode(serialize(track));
const restored = deserialize(decode(text));

serialize() validates that the data is JSON-safe and deserialize() validates unknown input. See persistence and migrating saved data.

Continue reading

Remedia configuration

On this page