Rest

A wrapper for the Lavalink REST API that streamlines interactions with Lavalink kinda like how a Command Block simplifies complex commands in Minecraft.

Constructor

new Rest(node)

Methods

.setSessionId()

Connects to the Lavalink server using the WebSocket.

ParameterTypeDescription
sessionIdStringThe session ID.

Returns: String

Exemple

<Rest>.setSessionId(sessionId);

.getAllPlayers()

Retrieves all the players that are currently running on the node.

Returns: Promise

Exemple

<Rest>.getAllPlayers();

.updatePlayer(options)

Sends a PATCH request to the node to update player related data.

ParameterTypeDescription
optionsplayOptionsThe session ID.

Returns: Promise

Exemple

<Rest>.updatePlayer({
    guildId: this.options.guildId,
    /** Pauses the player. This is just an example. */
    data: { paused: toggle }
});

.get(path)

Sends a GET request to the specified endpoint and returns the response data.

Returns: Promise

ParameterTypeDescription
pathRouteLikeThe path.

Exemple:

<Rest>.get(`endpoint here`)

.patch(endpoint, body)

Sends a PATCH request to the specified endpoint and returns the response data.

Returns: Promise

ParameterTypeDescription
endpointRouteLikeThe path.
bodyunknownThe parameters you'd like to modify.

Exemple:

<Rest>.patch(`endpoint here`, {
    parameters: here
})

.post(endpoint, body)

Sends a POST request to the specified endpoint and returns the response data.

Returns: Promise

ParameterTypeDescription
endpointRouteLikeThe path.
bodyunknownThe parameters you'd like to modify.

Exemple:

<Rest>.post(`endpoint here`, {
    parameters: here
})

.get(endpoint)

Sends a GET request to the specified endpoint and returns the response data.

Returns: Promise

ParameterTypeDescription
endpointRouteLikeThe path.

Exemple:

<Rest>.delete(`endpoint here`)