Manager
The Manager is the central hub of Moonlink.js. It coordinates nodes, audio players, and the connection with Discord.
The Manager class coordinates the connection between the Discord client, Lavalink nodes, and the database.
Constructor
new Manager(config)
Creates the central hub for Moonlink.js.
The main configuration object.
IManagerConfig
An array of Lavalink nodes to connect to.
Global settings for the manager, players, and system behavior.
Optional. A function to send packets to Discord. Required if you do not use a Connector.
Properties
Manager Properties
Core components and state accessible via the Manager instance.
Sub-Managers
The interface for managing voice connections (create, destroy, get).
The interface for managing Lavalink node connections and stats.
The internal database for queue persistence.
State & Config
The readonly configuration object with defaults applied.
A map of nodes that are connected and ready for requests.
Whether init() has been completed.
The Bot ID used for this session.
Methods
init(clientId)
init(clientId)#
→Promise<this>Initializes the manager, connects to the database, and establishes connections to nodes.
The Discord Client ID.
use(connector, client)
use(connector, client)#
→thisInjects a Connector to bridge Moonlink.js with your Discord library.
The connector instance.
The client instance of your Discord library.
search(options)
search(options)#
→Promise<SearchResult>Searches for tracks, playlists, or albums.
The search configuration object.
ISearchQuery
The search term or URL.
Force a specific source.
The requester of the track.
Optional node ID.
packetUpdate(packet)
packetUpdate(packet)#
→Promise<void>Handles raw voice updates from Discord.
The raw data packet.
decodeTrack(encoded)
decodeTrack(encoded)#
→ITrackDecodes a Lavalink base64 track string.
The base64 string.
encodeTrack(track)
encodeTrack(track)#
→stringEncodes a track object into a Lavalink base64 string.
The track information object.
Events
You can listen to any of these events using manager.on(eventName, listener).
Manager Events
Events emitted by the Manager instance during its lifecycle.
Debug
Emitted for general debugging logs.
Node Events
Emitted when a node is created.
Emitted when a node is ready.
Emitted when a node connects.
Emitted when a node successfully reconnects.
Emitted when a node attempts to reconnect.
Emitted when a node session is resumed.
Emitted when a node disconnects.
Emitted when a node has an error.
Emitted when a node is destroyed.
Emitted when a raw packet is received from a node.
Emitted when a node's connection state changes.
Player Events
Emitted when a player is created.
Emitted when a player is destroyed.
Emitted when player update data is received.
Emitted when a player is transferred to a different node.
Emitted when a player starts connecting to voice.
Emitted when a player successfully connects to voice.
Emitted when a player is fully ready.
Emitted when a player starts resuming.
Emitted when a player has successfully resumed.
Emitted when a player disconnects from voice.
Emitted when a player attempts to reconnect.
Emitted when a player moves to a different voice channel.
Emitted when a player's mute state changes.
Emitted when a player's deaf state changes.
Emitted when a player's suppression state changes.
Emitted when autoPlay is toggled.
Emitted when autoLeave is toggled.
Emitted when the volume is changed.
Emitted when the loop mode is changed.
Emitted when the text channel is updated.
Emitted when the voice channel ID is updated manually.
Emitted when the player's node identifier is updated.
Emitted when player recovery begins.
Emitted when player recovery succeeds.
Emitted when player recovery fails.
Failover Events
Emitted when multiple players are moved due to node failure.
Emitted when players cannot be moved and are left without a node.
Player Triggered Events
Emitted when play() is called.
Emitted when pause() is called.
Emitted when resume() is called.
Emitted when stop() is called.
Emitted when skip() is called.
Emitted when seek() is called.
Emitted when shuffle() is called.
Emitted when back() is called.
Track Events
Emitted when a track starts playing.
Emitted when a track finishes playing.
Emitted when a track gets stuck.
Emitted when a track errors.
Queue Events
Emitted when tracks are added.
Emitted when tracks are removed.
Emitted when tracks are moved.
Emitted when a range of tracks is removed.
Emitted when tracks are duplicated.
Emitted when the queue is empty.
Other Events
Emitted when filters are updated.
Emitted when the voice connection closes.
Emitted when voice session ID changes.
Emitted when a track plays via AutoPlay.
Emitted when the bot auto-leaves.