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
The main Moonlink Manager instance.
The Lavalink node currently handling this player.
The queue of tracks waiting to be played.
Audio filter controls (equalizer, karaoke, timescale, etc.).
Configuration
The ID of the guild this player belongs to.
The ID of the currently connected voice channel.
The ID of the text channel used for updates.
Current volume (0-1000). Default: 100.
Loop mode: 'off', 'track', or 'queue'.
Whether auto-play is enabled.
State
True if a track is currently playing.
True if playback is paused.
True if connected to a voice channel.
The track currently being played.
History of previously played tracks.
Methods
connect(options)
connect(options)#
→Promise<this>Connects the player to the voice channel specified in voiceChannelId.
Optional voice state settings.
options
Whether to deafen the bot on join. Default: true.
Whether to mute the bot on join. Default: false.
await player.connect({ selfDeaf: true });
disconnect()
disconnect()#
→Promise<this>Disconnects the player from the voice channel but keeps the player instance active (paused).
await player.disconnect();
play(options)
play(options)#
→Promise<boolean>Starts playback. If a track is provided, it is added to the queue. If the queue is not empty, it starts playing.
The track to play or play options.
PlayOptions
The track object to play.
Alternatively, a base64 encoded track string.
If true, will not replace the currently playing track.
// Play a specific track
await player.play(myTrack);
// Or just start the queue
await player.play();
pause()
resume()
stop()
Stops the current track immediately. The queue remains intact.
await player.stop();
skip(position)
skip(position)#
→Promise<boolean>Skips the current track. If position is provided, it skips to that specific index in the queue.
Optional. The index in the queue to skip to.
// Skip current song
await player.skip();
// Skip to the 3rd song in queue
await player.skip(2);
seek(position)
seek(position)#
→Promise<this>Seeks to a specific position in the current track.
The position in milliseconds.
// Seek to 1 minute
await player.seek(60000);
setVolume(volume)
setVolume(volume)#
→thisSets the playback volume.
Volume level (0-1000).
player.setVolume(50); // 50%
setLoop(loop)
setLoop(loop)#
→thisSets the loop mode.
Mode: 'off', 'track', or 'queue'.
player.setLoop('track');
shuffle()
destroy()
Totally destroys the player, disconnects voice, and cleans up data on the node.
await player.destroy("Finished playing");
transferNode(node)
transferNode(node)#
→Promise<boolean>Moves the player to a different Lavalink node seamlessly.
The target node or its identifier.
await player.transferNode(backupNode);
back()
Plays the previously played track (if available in history).
await player.back();