Skip to main content
Version: 2.0.0

Rest

ruvyrias


ruvyrias / Rest

Class: Rest

Defined in: src/Rest.ts:11

Provides a RESTful interface for making HTTP requests to interact with the Lavalink server. This class facilitates actions such as retrieving player information, updating player settings, and managing tracks.

Constructors

Constructor

new Rest(ruvyrias, node): Rest

Defined in: src/Rest.ts:17

Parameters

ruvyrias

Ruvyrias

node

Node

Returns

Rest

Properties

ruvyrias

readonly ruvyrias: Ruvyrias

Defined in: src/Rest.ts:12


sessionId

sessionId: null | string

Defined in: src/Rest.ts:15


url

readonly url: string

Defined in: src/Rest.ts:13

Methods

delete()

delete(endpoint): Promise<null>

Defined in: src/Rest.ts:141

Performs an HTTP DELETE request to the given endpoint.

Parameters

endpoint

`/${string}`

The endpoint to send the DELETE request to.

Returns

Promise<null>

A Promise that resolves once the deletion is complete, or null on failure.


deletePlayer()

deletePlayer(guildId): Promise<null>

Defined in: src/Rest.ts:61

Destroys the player associated with the specified guild ID.

Parameters

guildId

string

The ID of the guild whose player should be destroyed.

Returns

Promise<null>

A Promise that resolves once the player is removed.


get()

get(path): Promise<null | RestMethodGet>

Defined in: src/Rest.ts:72

Performs an HTTP GET request to the given path.

Parameters

path

`/${string}`

The endpoint path for the GET request.

Returns

Promise<null | RestMethodGet>

A Promise resolving with the server response data or null if the request fails.


getAllPlayers()

getAllPlayers(): Promise<null | ErrorResponses | Player[]>

Defined in: src/Rest.ts:40

Retrieves information about all players in the current session.

Returns

Promise<null | ErrorResponses | Player[]>

A Promise resolving to an array of players, an error response, or null if no players exist.


getRoutePlannerStatus()

getRoutePlannerStatus(): Promise<unknown>

Defined in: src/Rest.ts:162

Retrieves the status of the Lavalink RoutePlanner.

Returns

Promise<unknown>

A Promise resolving with the route planner status information.


patch()

patch(endpoint, body): Promise<null | Player>

Defined in: src/Rest.ts:94

Performs an HTTP PATCH request to the given endpoint with the provided data.

Parameters

endpoint

`/${string}`

The endpoint to patch.

body

any

The data to send in the PATCH request.

Returns

Promise<null | Player>

A Promise resolving to the updated player or null if the request fails.


post()

post(endpoint, body): Promise<null | Track[]>

Defined in: src/Rest.ts:118

Performs an HTTP POST request to the given endpoint with the provided data.

Parameters

endpoint

`/${string}`

The endpoint to send the POST request to.

body

any

The data to include in the POST request body.

Returns

Promise<null | Track[]>

A Promise resolving to an array of tracks or null if the request fails.


setSessionId()

setSessionId(sessionId): void

Defined in: src/Rest.ts:30

Sets the session ID for the REST instance, used in subsequent requests.

Parameters

sessionId

string

The session ID to assign to this REST instance.

Returns

void


unmarkFailedAddress()

unmarkFailedAddress(address): Promise<unknown>

Defined in: src/Rest.ts:172

Unmarks a failed IP address in the RoutePlanner, freeing it for use.

Parameters

address

string

The address to unmark as failed (must be in the same IP block).

Returns

Promise<unknown>

A Promise resolving with the response or an error if the route planner is not enabled.


updatePlayer()

updatePlayer(options): Promise<null | Player | ErrorResponses>

Defined in: src/Rest.ts:51

Updates a player with the provided options.

Parameters

options

PlayOptions

Options including guildId and data to update the player.

Returns

Promise<null | Player | ErrorResponses>

A Promise resolving to the updated player, an error response, or null if the update failed.