Discord Player
API reference

Player

Constructor options, initialization, searching, playing, and lifecycle.

You are reading the v8 docsDev

DiscordPlayer is exported as DiscordPlayer and as Player.

import { Player } from 'discord-player';

const player = new Player({ send });

await player.initialize(botUserId);

Constructor

new Player(options: DiscordPlayerOptions)

OptionTypeDescription
send(guildId, payload) => void | Promise<void>Required. Sends voice requests through the shard that owns the guild
nodesRemediaNodeConfig[]Audio nodes. Defaults to one embedded node named local
pluginsPluginRegistration[]Source plugins registered with the Player
crossfadeCrossfadeOptionsDefault crossfade for new queues. Off by default
resolveVoiceChannelUsers(guildId, channelId) => Promise<string[] | null>Member IDs for emptiness policies
blockExtractorsstring[]Plugin and extractor IDs to disable
probeTimeoutnumberTimeout for legacy extractor metadata probing
requestTimeoutMsnumberRemedia request timeout. Default 15000
maxPendingRequestsnumberRemedia concurrent requests per remote node. Default 128
onBeforeCreateStream, onStreamExtracted, onAfterCreateStreamfunctionsResource hooks

The Remedia client options botUserId and selectNode are not options of the Player. initialize() takes the user ID, and node selection is a queue option.

Methods

MethodReturnsDescription
initialize(botUserId)Promise<void>Starts plugins and Remedia. Call it after the bot is ready
receive(payload)voidForwards a raw gateway packet. Ignored before initialize() and after destroy()
search(query, options?)Promise<SearchResult>Finds tracks. String queries need a plugin
play(channel, resource, options?)Promise<PlayerNodeInitializationResult>Creates or reuses the queue and plays
createQueue(guildId, options?)Promise<GuildQueue>Gets or creates a queue
getQueue(guildId)GuildQueue | nullGets an existing queue
deleteQueue(guildId)Promise<boolean>Destroys a queue
getRemedia()RemediaClientThe Remedia client. Throws before initialization
getClientId()stringThe bot user ID. Throws before initialization
debug(message)voidEmits a debug event
destroy()Promise<void>Destroys queues, plugins, and the Remedia client

Properties

PropertyDescription
nodesThe guild queue manager (GuildNodeManager)
nodeSnapshotsStatus of the Remedia nodes, or null before initialization
remediaThe Remedia client, or null before initialization
pluginsThe plugin registry
extractorsThe v7 extractor registration API
eventsGuild queue events. See events
contextPlayer context
lyricsLyrics lookup
statisticsCounts of queues, upcoming tracks, and active queues
signalAbortSignal that aborts as soon as destroy() starts
id, versionInstance ID and package version

play()

const { queue, track, playerResult, searchResult } = await player.play({ guildId, channelId }, query, {
  connectTimeoutMs: 120_000,
});
ArgumentAccepts
channelA voice channel object, { guildId, channelId }, or a channel ID with options.guildId
resourceA string query, Track, Track[], Playlist, or SearchResult
optionsSearch options, queue play options, nodeOptions, and guildId
ResultDescription
queueThe queue that received the request
trackThe selected track, or null for an empty search
playerResultThe immediate Remedia result when a track started, otherwise null
searchResultThe tracks and playlist found
resourceThe value you passed in

connectTimeoutMs sets the initial voice join deadline. The default is 100 seconds. It does not apply to channel moves.

nodeOptions holds queue defaults and applies only when the queue is created.

Lifetime signal

player.signal is an AbortSignal for the Player's lifetime. It aborts when destroy() starts, before cleanup finishes, and stays aborted if cleanup fails. Await destroy() to know when cleanup is done.

Destroying one queue does not abort player.signal.

Continue reading

GuildQueue

On this page