Skip to main content
Version: v2.9.1

Player

Table of Contentsโ€‹

Class Definitionโ€‹

export class Player {}

Propertiesโ€‹

Property Type Description
autoplayTriesnumberThe number of autoplay tries.
bandsEqualizerBand[]The equalizer bands.
clusterIdnumberThe cluster ID.
dynamicRepeatbooleanThe dynamic repeat state.
filtersFiltersThe filters.
guildIdstringThe guild ID the Player belongs to.
isAutoplaybooleanWhether autoplay is enabled.
managerManagerThe Manager instance.
nodeNodeThe Node instance.
nowPlayingMessageMessageThe now playing message.
pausedbooleanWhether the player is paused.
playingbooleanWhether the player is playing.
positionnumberThe player position.
queueQueueThe queue.
queueRepeatbooleanThe queue repeat state.
stateStateTypesThe player state.
textChannelIdstringThe text channel id the Player is bound to.
trackRepeatbooleanThe track repeat state.
voiceChannelIdstringThe voice channel id the Player is bound to.
voiceStateVoiceStateThe voice state the Player is in.
volumenumberThe player volume.

Constructorโ€‹

new Player(options: PlayerOptions)
Parameter Type Description Optional
optionsPlayerOptionsThe player options.

Methodsโ€‹

autoMoveNode()โ€‹

async autoMoveNode(): Promise<Player | void>

Automatically moves the player to an usable node.

Returnsโ€‹

Type Description
Promise<Player | void>The player.

connect()โ€‹

connect(): void

Connects the player to the voice channel.


deleteSponsorBlock()โ€‹

warning

โš ๏ธ This method only works when the players node has the sponsor block plugin.

async deleteSponsorBlock(): Promise<void>

Deletes the sponsor block.


destroy()โ€‹

async destroy(disconnect: boolean = true): Promise<boolean>

Destroys the player.

Parametersโ€‹

Parameter Type Description Optional
disconnectbooleanWhether to disconnect the player from the voice channel.

Returnsโ€‹

Type Description
Promise<boolean>Whether the player was successfully destroyed.

disconnect()โ€‹

async disconnect(): Promise<void>

Disconnects the player from the voice channel.


get()โ€‹

get<T>(key: string): T

Retrieves custom data associated with a given key.

Parametersโ€‹

Parameter Type Description Optional
keystringThe key to get the value from.

Returnsโ€‹

Type Description
anyThe value.

getCurrentLyrics()โ€‹

warning

โš ๏ธ This method only works when the players node has the LavaLyrics plugin.

async getCurrentLyrics(skipTrackSource: boolean = false): Promise<Lyrics>

Retrieves the current lyrics for the playing track.

Parametersโ€‹

Parameter Type Description Optional
skipTrackSourcebooleanWhether to skip the track source.

Returnsโ€‹

Type Description
Promise<Lyrics>The lyrics.

getRecommendedTracks()โ€‹

async getRecommendedTracks(track: Track): Promise<Track[]>

Retrieves recommended tracks for the current track.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe track to get recommended tracks for.

Returnsโ€‹

Type Description
Promise<Track[]>The recommended tracks.

getSponsorBlock()โ€‹

warning

โš ๏ธ This method only works when the players node has the sponsor block plugin.

async getSponsorBlock(): Promise<SponsorBlockSegment[]>

Gets the sponsorblock for the player.

Returnsโ€‹

Type Description
Promise<SponsorBlockSegment[]>The sponsorblock segments.

init()โ€‹

init(manager: Manager): void

Initializes the player.

Parametersโ€‹

Parameter Type Description Optional
managerManagerThe manager instance.

moveNode()โ€‹

async moveNode(identifier: string): Promise<Player>

Moves the player to a different node.

Parametersโ€‹

Parameter Type Description Optional
identifierstringThe node identifier to move the player to.

Returnsโ€‹

Type Description
Promise<Player>The player.

pause()โ€‹

async pause(pause: boolean): Promise<this>

Pauses the player.

Parametersโ€‹

Parameter Type Description Optional
pausebooleanWhether to pause the player.

Returnsโ€‹

Type Description
Promise<this>The player.

play()โ€‹

async play(): Promise<Player>
async play(track: Track): Promise<Player>
async play(options: PlayOptions): Promise<Player>
async play(track: Track, options: PlayOptions): Promise<Player>

Plays a track or starts playback with the specified options.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe track to play.
optionsPlayOptionsThe play options.

Returnsโ€‹

Type Description
Promise<Player>The player.

previous()โ€‹

async previous(): Promise<this>

Skips to the previous track in the queue.

Returnsโ€‹

Type Description
Promise<this>The player.

removeVoiceReceiver()โ€‹

warning

โš ๏ธ This method only works when a player is connected to a NodeLink node.

async removeVoiceReceiver(): Promise<void>

Removes the voice receiver from the player.


restart()โ€‹

async restart(): Promise<Player>

Restarts the current track.

Returnsโ€‹

Type Description
Promise<Player>The player.

async search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>

Searches for tracks based on the query.

Parametersโ€‹

Parameter Type Description Optional
querystring | SearchQueryThe query to search for.
requesterTThe requester.

Returnsโ€‹

Type Description
Promise<SearchResult>The search result.

seek()โ€‹

async seek(position: number): Promise<Player>

Seeks to the specified position in the current track.

Parametersโ€‹

Parameter Type Description Optional
positionnumberThe position to seek to.

Returnsโ€‹

Type Description
Promise<Player>The player.

set()โ€‹

set(key: string, value: unknown): void

Sets a custom property on the player.

Parametersโ€‹

Parameter Type Description Optional
keystringThe key to set.
valueunknownThe value to set.

Returnsโ€‹

Type Description
voidThe player.

setAutoplay()โ€‹

setAutoplay<T = unknown>(autoplayState: boolean, AutoplayUser?: T, tries?: number): this

Sets the autoplay option on the player.

Parametersโ€‹

Parameter Type Description Optional
autoplayStatebooleanThe autoplay option.
AutoplayUserTThe bot user.
triesnumberThe number of tries.

Returnsโ€‹

Type Description
thisThe player.

setDynamicRepeat()โ€‹

async setDynamicRepeat(repeat: boolean, ms: number): Promise<this>

Sets the dynamic repeat option on the player.

Parametersโ€‹

Parameter Type Description Optional
repeatbooleanThe dynamic repeat option.
msnumberThe time in milliseconds.

Returnsโ€‹

Type Description
Promise<this>The player.

setNowPlayingMessage()โ€‹

setNowPlayingMessage<T = Message>(message: T): Message

Sets the now playing message on the player.

Parametersโ€‹

Parameter Type Description Optional
messageMessageThe now playing message.

Returnsโ€‹

Type Description
MessageThe now playing message.

setQueueRepeat()โ€‹

setQueueRepeat(repeat: boolean): this

Sets the queue repeat option on the player.

Parametersโ€‹

Parameter Type Description Optional
repeatbooleanThe queue repeat option.

Returnsโ€‹

Type Description
thisThe player.

setSponsorBlock()โ€‹

warning

โš ๏ธ This method only works when the players node has the sponsor block plugin.

async setSponsorBlock(segments: SponsorBlockSegment[] = [SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]): Promise<void>

Sets the sponsor block segments on the player.

Parametersโ€‹

Parameter Type Description Optional
segmentsSponsorBlockSegment[]The sponsor block segments.

setTextChannelId()โ€‹

setTextChannelId(channel: string): this

Sets the text channel id on the player.

Parametersโ€‹

Parameter Type Description Optional
channelstringThe text channel id.

Returnsโ€‹

Type Description
thisThe player.

setTrackRepeat()โ€‹

setTrackRepeat(repeat: boolean): this

Sets the track repeat option on the player.

Parametersโ€‹

Parameter Type Description Optional
repeatbooleanThe track repeat option.

Returnsโ€‹

Type Description
thisThe player.

setVoiceChannelId()โ€‹

setVoiceChannelId(channel: string): this

Sets the voice channel id on the player.

Parametersโ€‹

Parameter Type Description Optional
channelstringThe voice channel id.

Returnsโ€‹

Type Description
thisThe player.

setVolume()โ€‹

async setVolume(volume: number): Promise<this>

Sets the volume on the player.

Parametersโ€‹

Parameter Type Description Optional
volumenumberThe volume.

Returnsโ€‹

Type Description
thisThe player.

setupVoiceReceiver()โ€‹

warning

โš ๏ธ This method only works when a player is connected to a NodeLink node.

async setupVoiceReceiver(): Promise<void>

Sets up the voice receiver on the player.


stop()โ€‹

async stop(amount?: number): Promise<this>

Stops the player and optionally removes tracks from the queue.

Parametersโ€‹

Parameter Type Description Optional
amountnumberThe amount of tracks to remove from the queue.

Returnsโ€‹

Type Description
Promise<this>The player.

switchGuild()โ€‹

async switchGuild(newOptions: PlayerOptions, force: boolean = false): Promise<Player>

Switches the guild on the player.

Parametersโ€‹

Parameter Type Description Optional
newOptionsPlayerOptionsThe new options for the player.
forcebooleanWhether to force the switch.

Returnsโ€‹

Type Description
Promise<Player>The player.