Star ✨ on GitHub

Player

Represents an active audio session for a specific guild. It controls playback, queue management, filters, and voice connection state.

The Player class is the heart of the audio session. Every guild playing music has one Player instance. It manages the queue, controls the playback flow (play, pause, skip), and handles voice channel connections.

Properties

Player Properties

Core state and configuration for the audio player.

References

managerManager

The main Moonlink Manager instance.

nodeNode

The Lavalink node currently handling this player.

queueQueue

The queue of tracks waiting to be played.

filtersFilters

Audio filter controls (equalizer, karaoke, timescale, etc.).

Configuration

guildIdstring

The ID of the guild this player belongs to.

voiceChannelIdstring

The ID of the currently connected voice channel.

textChannelIdstring

The ID of the text channel used for updates.

volumenumber

Current volume (0-1000). Default: 100.

loopPlayerLoop

Loop mode: 'off', 'track', or 'queue'.

autoPlayboolean

Whether auto-play is enabled.

State

playingboolean

True if a track is currently playing.

pausedboolean

True if playback is paused.

connectedboolean

True if connected to a voice channel.

currentTrack | null

The track currently being played.

Methods

connect(options)

connect(options)#

Connects the player to the voice channel specified in voiceChannelId.

optionsobject

Optional voice state settings.

options

selfDeafboolean

Whether to deafen the bot on join. Default: true.

selfMuteboolean

Whether to mute the bot on join. Default: false.

Example
await player.connect({ selfDeaf: true });

disconnect()

disconnect()#

Disconnects the player from the voice channel but keeps the player instance active (paused).

Example
await player.disconnect();

play(options)

play(options)#

Starts playback. If a track is provided, it is added to the queue. If the queue is not empty, it starts playing.

optionsobject | Track

The track to play or play options.

PlayOptions

trackTrack

The track object to play.

encodedstring

Alternatively, a base64 encoded track string.

noReplaceboolean

If true, will not replace the currently playing track.

Example
// Play a specific track
await player.play(myTrack);

// Or just start the queue
await player.play();

pause()

pause()#

Pauses playback.

Example
await player.pause();

resume()

resume()#

Resumes playback if paused.

Example
await player.resume();

stop()

stop()#

Stops the current track immediately. The queue remains intact.

Example
await player.stop();

skip(position)

skip(position)#

Skips the current track. If position is provided, it skips to that specific index in the queue.

positionnumber

Optional. The index in the queue to skip to.

Example
// Skip current song
await player.skip();

// Skip to the 3rd song in queue
await player.skip(2);

seek(position)

seek(position)#

Seeks to a specific position in the current track.

positionnumber required

The position in milliseconds.

Example
// Seek to 1 minute
await player.seek(60000);

setVolume(volume)

Sets the playback volume.

volumenumber required

Volume level (0-1000).

Example
player.setVolume(50); // 50%

setLoop(loop)

Sets the loop mode.

loopPlayerLoop required

Mode: 'off', 'track', or 'queue'.

Example
player.setLoop('track');

shuffle()

shuffle()#

Shuffles the current queue.

Example
player.shuffle();

destroy()

destroy()#

Totally destroys the player, disconnects voice, and cleans up data on the node.

Example
await player.destroy("Finished playing");

transferNode(node)

transferNode(node)#

Moves the player to a different Lavalink node seamlessly.

nodeNode | string required

The target node or its identifier.

Example
await player.transferNode(backupNode);

back()

back()#

Plays the previously played track (if available in history).

Example
await player.back();

restart()

restart()#

Restarts the player, useful for recovering from connection issues. It re-establishes voice and resumes the track/queue.

Example
await player.restart();