Skip to main content
Version: v2.9.0

Rest

Table of Contentsโ€‹

Class Definitionโ€‹

export class Rest {}

Propertiesโ€‹

Property Type Description
isNodeLinkbooleanWhether the Rest instance is a NodeLink instance.
managerManagerThe manager instance.
nodeNodeThe node instance.
passwordstringThe password used to connect to the node.
sessionIdstringThe session ID.
urlstringThe URI of the node.

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 to delete.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

destroyPlayer()โ€‹

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

Sends a DELETE request to the server to destroy the player.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild ID.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

get()โ€‹

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

Sends a GET request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint to get.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

getAllPlayers()โ€‹

async getAllPlayers(): Promise<unknown>

Sends a GET request to the server to get all players.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

patch()โ€‹

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

Sends a PATCH request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint to patch.
bodyunknownThe body to patch.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

post()โ€‹

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

Sends a POST request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint to post.
bodyunknownThe body to post.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

put()โ€‹

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

Sends a PUT request to the specified endpoint.

Parametersโ€‹

Parameter Type Description Optional
endpointstringThe endpoint to put.
bodyunknownThe body to put.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

setSessionId()โ€‹

setSessionId(sessionId: string): string

Sets the session ID.

Parametersโ€‹

Parameter Type Description Optional
sessionIdstringThe session ID to set.

Returnsโ€‹

Return Description
stringThe session ID.

updatePlayer()โ€‹

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

Sends a PATCH request to the server to update the player.

Parametersโ€‹

Parameter Type Description Optional
optionsRestPlayOptionsThe options to update.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

updateSession()โ€‹

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

Sends a PATCH request to update the session's resuming status and timeout.

Parametersโ€‹

Parameter Type Description Optional
resumingbooleanWhether the session is resuming.
timeoutnumberThe session timeout.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.