Discord Player
API reference

Events

Every Player and queue event with its arguments, in the order your listener receives them.

You are reading the v8 docsDev
EmitterUse for
player.events.on()Events of one guild queue. The first argument is the queue
player.on()Player events, and Remedia node and session events

The GuildQueueEvents constant lists the queue event names.

player.events.on('playerSkip', (queue, track, reason, description) => {
  console.log(queue.guildId, track.title, reason, description);
});

Queue events

Arguments are listed after queue. A trailing rawEvent is the original Remedia event.

Queue and tracks

EventArguments
queueCreate, queueDeletenone
audioTrackAdd, audioTrackRemovetrack
audioTracksAdd, audioTracksRemovetracks
emptyQueuenone
willPlayTracktrack
willAutoPlaytracks, done
playerTriggertrack, reason
debugmessage
errorerror, rawEvent?

Playback

EventArguments
playerStarttrack, rawEvent?
playerFinishtrack, rawEvent?
playerSkiptrack, reason, description, rawEvent?
playerStoptrack | null, rawEvent?
playerErrorerror, track, rawEvent?
playerPause, playerResume, playerSeekrawEvent
volumeChangeoldVolume, newVolume, rawEvent?
audioFiltersUpdateoldGraph, newGraph, rawEvent?

willAutoPlay needs a listener that calls done(trackOrNull). Without a listener the queue picks a track itself. Skipping, stopping, queue changes, and destruction cancel a pending choice and ignore a late done.

willPlayTrack is informational. To change the source, use a resource hook.

Voice

EventArguments
connection, connectionDestroyednone
disconnectrawPacket?
emptyChannel, channelPopulatenone
voiceStateUpdateprevious | null, current, rawPacket
voiceConnectionStateChangepreviousState, state, rawEvent
sessionDisposedrawEvent

voiceStateUpdate reports Discord member changes. A normalized state has guildId, userId, channelId, and the server mute and suppress flags when available. previous is null when unknown.

voiceConnectionStateChange reports the audio connection. A failed connection emits error with the Remedia event as its second argument.

emptyChannel, channelPopulate, and disconnect come from the queue's own voice tracking and do not depend on Remedia.

Crossfade and staging

EventArguments
willPrepareNextTracktrack, rawEvent
stageReadytrack | null, rawEvent
stageFailedtrack | null, error, rawEvent?
stageInvalidatedtrack | null, rawEvent
transitionCancelledtrack | null, rawEvent

Preparation is informational and can repeat after a cancel or a retry. It starts before the source is resolved. Staging never fires playerStart. Promotion does. A staging failure does not mean the current track failed.

A null track means the staged track could not be matched reliably.

Sessions and nodes

EventArguments
sessionEventname, rawEvent
sessionResumed, sessionLostrawEvent
guildAssigned, guildReleased, guildMigratedrawEvent

sessionEvent reports every Remedia session event, including stale ones, before the queue processes them. It never changes queue state.

The guild events go only to queues that already exist.

Native event types

The trailing rawEvent types come from @remedia/client:

Queue eventRemedia type
willPrepareNextTrackDiscordSessionEvents['prepareRequested'][0]
stageReadyDiscordSessionEvents['stageReady'][0]
stageFailedDiscordSessionEvents['stageFailed'][0]
stageInvalidatedDiscordSessionEvents['stageInvalidated'][0]
transitionCancelledDiscordSessionEvents['transitionCancelled'][0]
sessionDisposedDiscordSessionEvents['sessionDisposed'][0]
audioFiltersUpdateDiscordSessionEvents['filterChanged'][0]
voiceConnectionStateChangeDiscordSessionEvents['voiceStateChanged'][0]
error from a voice failureDiscordSessionEvents['voiceFailed'][0]
sessionResumed, sessionLost, guildAssigned, guildReleased, guildMigratedThe matching RemediaClientEvents payload

Discord Player exports both DiscordSessionEvents and RemediaClientEvents as types.

Application-owned changes, such as adding a track or queueCreate, have no Remedia event, so none is added.

Remedia events on the player

player.on() receives every RemediaClientEvents event with its unchanged arguments:

nodeConnected, nodeDisconnected, sessionResumed, sessionLost, nodeEvent, eventsLost, guildAssigned, guildReleased, guildMigrated, plus the Remedia playback and voice session events.

It also emits debug, error, and voiceStateUpdate(guildId, packet).

player.on('nodeDisconnected', ({ node, error }) => {
  console.warn(`Node ${node.id} disconnected`, error);
});

Player events describe the whole client. Queue events describe one guild's queue. They are separate scopes, so a Remedia playback event can appear on both.

Continue reading

Plugins

On this page