Manager

Automata's Manager is the main hub for interacting with Lavalink like the iDROID that assists Snake in managing missions and communication in Metal Gear Solid V.

Constructor

new Manager(options: AutomataOptions)
Parameter (AutomataOptions)TypeDescription
nodesNodesThe map of nodes.
defaultPlatformStringThe default platform used by the manager to fetch songs. Default platform is Deezer.
reconnectTimeoutNumberThe time the manager will wait before trying to reconnect to a node.
reconnectTriesNumberThe amount of times the player will try to reconnect to a node.
resumeStatusBooleanUsed to enable / disable resuming.
resumeTimeoutNumberThe time the manager will wait before trying to resume the previous session.

Properties

_.nodes

Where the nodes are initially saved.

Type: Node

.nodes

A map of the nodes.

Type: Map<string, Node>

.players

A map of the players.

Type: Map<string, Player>

.options

Where the options are initially stored in the constructor.

Type: AutomataOptions

Methods

.init(client)

This method initializes the manager.

ParameterTypeDescription
clientClientThe Discord.js Client class.

Returns: void

Exemple

/** Must be present in your bot's ready.js. */
<Automata>.init(<client>)

.addNode(node)

Adds a new node to the node pool and establishes a connection to it.

ParameterTypeDescription
nodeNodeOptionsThe options need for Automata to establish a connection to the node.

Returns: Node

Exemple

<Manager>.addNode({ name: 'ATM_Node01', host: 'localhost', port: 3000, password: 'Capybara' })

.removeNode(identifier)

Removes the specified node from the node pool and disconnects from it.

ParameterTypeDescription
identifierStringThe name of the node that you want to remove.

Returns: void

Exemple

<Manager>.removeNode('ATM_Node01')

.leastUsedNodes

Returns the least used node.

Returns: Node

Exemple

<Manager>.leastUsedNodes()

.getNode(identifier)

Retrieves the specified node.

ParameterTypeDescription
identifierStringThe name of the node that you want to retrieve info for.

Returns: Node | Node

Exemple

<Manager>.getNode('ATM_Node01');

.create(options)

Creates a player or returns one if it already exists.

ParameterTypeDescription
optionsConnectionOptionsThe options needed to create a player.

Exemple

const player = client.manager.create({
    guildId: interaction.guild.id,
    voiceChannel: interaction.member.voice.channelId,
    textChannel: interaction.channelId,
    deaf: true,
});

.resolve({ query, requester })

Resolves the provided query.

ParameterTypeDescription
queryStringThe name / URL of the song you'd like to queue.
requesterObjectThe requester of the song (always a Discord.js User)

Returns: Promise

Exemple

const res = await client.manager.resolve({
    query: 'never gonna give you up (or some other song) / URL to a song,' 
    requester: interaction.user,
});

.getLavalinkStats()

Gets information regarding about the node's players, uptime, memory etc.

Returns: NodeStats

Exemple:

<Manager>.getLavalinkStats();

Events

nodeConnect

Emitted when Automata successfully connects to a Lavalink node.

ParameterType
nodeNode

nodeDisconnect

Emitted when Automata loses the connection to a Lavalink node.

ParameterType
nodeNode

nodeReconnect

Emitted when Automata successfully reconnects to a Lavalink node.

ParameterType
nodeNode

nodeError

Emitted when a Node related error occurs.

ParameterType
nodeNode
errorError

trackStart

Emitted when a player starts playing a new track.

ParameterType
playerPlayer
trackTrack

trackEnd

Emitted when a player finishes playing a track.

ParameterType
playerPlayer
trackTrack

trackStuck

Emitted when a track gets stuck while it is playing.

ParameterType
playerPlayer
trackTrack

queueEnd

Emitted when the player's queue has finished.

ParameterType
playerPlayer

playerUpdate

Emitted when the player gets updated.

ParameterType
playerPlayer

playerDestroy

Emitted when a player gets destroyed.

ParameterType
playerPlayer

socketClose

Emitted when the connection between the WebSocket and Discord voice servers drops.

ParameterType
playerPlayer
trackTrack