Skip to main content
Version: v2.10.1

Rest

Table of Contentsโ€‹

Class Definitionโ€‹

export class Rest {}

Propertiesโ€‹

Property Type Description
isNodeLinkbooleanWhether the connected node is a NodeLink node.
managerManagerThe Manager instance.

Constructorโ€‹

new Rest(node: Node, manager: Manager)
Parameter Type Description Optional
nodeNodeThe node instance.
managerManagerThe manager instance.

Methodsโ€‹

delete()โ€‹

async delete(endpoint: string): Promise<unknown>

Sends a DELETE request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint path.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

destroyPlayer()โ€‹

async destroyPlayer(guildId: string): Promise<unknown>

Sends a DELETE request to the Lavalink session to destroy the player for the given guild.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild ID of the player to destroy.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

get()โ€‹

async get(endpoint: string): Promise<unknown>

Sends a GET request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint path.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

getPlayer()โ€‹

async getPlayer(guildId: string): Promise<LavaPlayer>

Fetches the current Lavalink player state for the given guild from the active session.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild ID.

Returnsโ€‹

Type Description
Promise<LavaPlayer>The raw Lavalink player object.

patch()โ€‹

async patch(endpoint: string, body: unknown): Promise<unknown>

Sends a PATCH request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint path.
bodyunknownThe request body.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

post()โ€‹

async post(endpoint: string, body: unknown): Promise<unknown>

Sends a POST request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint path.
bodyunknownThe request body.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

put()โ€‹

async put(endpoint: string, body: unknown): Promise<unknown>

Sends a PUT request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint path.
bodyunknownThe request body.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

setSessionId()โ€‹

setSessionId(sessionId: string): string

Updates the active session ID. Called internally after a session resume.

Parametersโ€‹

Parameter Type Description Optional
sessionIdstringThe new session ID.

Returnsโ€‹

Type Description
stringThe set session ID.

updatePlayer()โ€‹

async updatePlayer(options: RestPlayOptions): Promise<unknown>

Sends a PATCH request to update the Lavalink player state for the given guild.

Parametersโ€‹

Parameter Type Description Optional
optionsRestPlayOptionsThe player update options.

Returnsโ€‹

Type Description
Promise<unknown>The response data.

updateSession()โ€‹

async updateSession(resuming: boolean, timeout: number): Promise<unknown>

Sends a PATCH request to update the session's resume configuration on the Lavalink node.

Parametersโ€‹

Parameter Type Description Optional
resumingbooleanWhether the session should be configured for resuming.
timeoutnumberThe resume timeout in seconds.

Returnsโ€‹

Type Description
Promise<unknown>The response data.