Manager

The core class responsible for managing nodes, players, and audio search.

new Manager(options: ManagerOptions)

Constructor Options

OptionTypeRequiredDescription
nodesarrayRequiredArray of Lavalink node configurations.
sendfunctionRequiredFunction to send voice data to Discord.
autoPlaybooleanOptionalAutomatically play the next track in queue.
autoResumebooleanOptionalResume playback after node reconnects.
autoMovebooleanOptionalMove players to another node if node disconnects.
shardsnumberOptionalNumber of shards the bot is using.
defaultSearchPlatformstringOptionalDefault search platform (e.g. 'youtube music').
trackPartialstring[]OptionalArray of track properties to keep after resolving.
clientIdstringOptionalDiscord client ID.
clientNamestringOptionalDiscord client name.
pluginsarrayOptionalArray of plugins to load.

Properties

nodes

The map of all connected nodes.

Map<string, Node>
players

The map of all active players.

Map<string, Player>
options

The options passed to the constructor.

ManagerOptions

Methods

init(clientId)this

Initiates the Manager and connects to all configured nodes. Must be called once your Discord client is ready.

ParameterTypeRequired
clientIdstringRequired
search(query, requester)Promise<SearchResult>

Searches the enabled sources based on the URL or search query. Supports YouTube, SoundCloud, Spotify, and more.

ParameterTypeRequired
querystring | SearchQueryRequired
requesterunknownOptional
create(options)Player

Creates a new player or returns an existing one for the specified guild.

ParameterTypeRequired
optionsPlayerOptionsRequired
get(guildId)Player | undefined

Returns a player for the specified guild, or undefined if it doesn't exist.

ParameterTypeRequired
guildIdstringRequired
destroy(guildId)void

Destroys a player if it exists.

ParameterTypeRequired
guildIdstringRequired
createNode(options)Node

Creates a node or returns one if it already exists.

ParameterTypeRequired
optionsNodeOptionsRequired
destroyNode(identifier)void

Destroys a node if it exists.

ParameterTypeRequired
identifierstringRequired
decodeTrack(track)Promise<TrackData>

Decodes a base64 encoded track string and returns TrackData.

ParameterTypeRequired
trackstringRequired
decodeTracks(tracks)Promise<TrackData[]>

Decodes multiple base64 encoded track strings and returns a TrackData array.

ParameterTypeRequired
tracksstring[]Required
updateVoiceState(data)void

Sends voice state data to the Lavalink server. This must be called on every raw Discord event.

ParameterTypeRequired
dataVoicePacketRequired

Events

Listen to Manager events using manager.on(event, callback)

nodeCreateNode

Emitted when a Node is created.

nodeDestroyNode

Emitted when a Node is destroyed.

nodeConnectNode

Emitted when a Node connects.

nodeReconnectNode

Emitted when a Node reconnects.

nodeDisconnectNode{ code, reason }

Emitted when a Node disconnects.

nodeErrorNodeError

Emitted when a Node has an error.

playerCreatePlayer

Emitted when a Player is created.

playerDestroyPlayer

Emitted when a Player is destroyed.

playerMovePlayeroldChannelnewChannel

Emitted when a Player moves to a new voice channel.

queueEndPlayer

Emitted when the player's queue ends.

trackStartPlayerTrackTrackStartEvent

Emitted when a track starts playing.

trackEndPlayerTrackTrackEndEvent

Emitted when a track ends.

trackStuckPlayerTrackTrackStuckEvent

Emitted when a track gets stuck during playback.

trackErrorPlayerTrackTrackExceptionEvent

Emitted when a track has a playback error.

socketClosedPlayerWebSocketClosedEvent

Emitted when a voice WebSocket connection closes.

nodeRawpayload

Emitted whenever any Lavalink event is received.