synthra-client
Version:
A user-friendly Lavalink client designed for NodeJS.
121 lines (120 loc) • 5.01 kB
TypeScript
import { Node } from "./Node";
import { Synthra } from "./Manager";
/** Handles the requests sent to the Lavalink REST API. */
export declare class Rest {
/** The Node that this Rest instance is connected to. */
private node;
/** The ID of the current session. */
private sessionId;
/** The password for the Node. */
private readonly password;
/** The URL of the Node. */
private readonly url;
/** The Manager instance. */
manager: Synthra;
constructor(node: Node, manager: Synthra);
/**
* Sets the session ID.
* This method is used to set the session ID after a resume operation is done.
* @param {string} sessionId The session ID to set.
* @returns {string} Returns the set session ID.
*/
setSessionId(sessionId: string): string;
/**
* Retrieves all the players that are currently running on the node.
* @returns {Promise<unknown>} Returns the result of the GET request.
*/
getAllPlayers(): Promise<unknown>;
/**
* Sends a PATCH request to update player related data.
* @param {playOptions} options The options to update the player with.
* @returns {Promise<unknown>} Returns the result of the PATCH request.
*/
updatePlayer(options: playOptions): Promise<unknown>;
/**
* Sends a DELETE request to the server to destroy the player.
* @param {string} guildId The guild ID of the player to destroy.
* @returns {Promise<unknown>} Returns the result of the DELETE request.
*/
destroyPlayer(guildId: string): Promise<unknown>;
/**
* Updates the session status for resuming.
* This method sends a PATCH request to update the session's resuming status and timeout.
*
* @param {boolean} resuming - Indicates whether the session should be set to resuming.
* @param {number} timeout - The timeout duration for the session resume.
* @returns {Promise<unknown>} The result of the PATCH request.
*/
updateSession(resuming: boolean, timeout: number): Promise<unknown>;
/**
* Sends a request to the specified endpoint and returns the response data.
* @param {string} method The HTTP method to use for the request.
* @param {string} endpoint The endpoint to send the request to.
* @param {unknown} [body] The data to send in the request body.
* @returns {Promise<unknown>} The response data of the request.
*/
private request;
/**
* Sends a GET request to the specified endpoint and returns the response data.
* @param {string} endpoint The endpoint to send the GET request to.
* @returns {Promise<unknown>} The response data of the GET request.
*/
get(endpoint: string): Promise<unknown>;
/**
* Sends a PATCH request to the specified endpoint and returns the response data.
* @param {string} endpoint The endpoint to send the PATCH request to.
* @param {unknown} body The data to send in the request body.
* @returns {Promise<unknown>} The response data of the PATCH request.
*/
patch(endpoint: string, body: unknown): Promise<unknown>;
/**
* Sends a POST request to the specified endpoint and returns the response data.
* @param {string} endpoint The endpoint to send the POST request to.
* @param {unknown} body The data to send in the request body.
* @returns {Promise<unknown>} The response data of the POST request.
*/
post(endpoint: string, body: unknown): Promise<unknown>;
/**
* Sends a PUT request to the specified endpoint and returns the response data.
* @param {string} endpoint The endpoint to send the PUT request to.
* @param {unknown} body The data to send in the request body.
* @returns {Promise<unknown>} The response data of the PUT request.
*/
put(endpoint: string, body: unknown): Promise<unknown>;
/**
* Sends a DELETE request to the specified endpoint.
* @param {string} endpoint - The endpoint to send the DELETE request to.
* @returns {Promise<unknown>} The response data of the DELETE request.
*/
delete(endpoint: string): Promise<unknown>;
}
interface playOptions {
guildId: string;
data: {
/** The base64 encoded track. */
encodedTrack?: string;
/** The track ID. */
identifier?: string;
/** The track time to start at. */
startTime?: number;
/** The track time to end at. */
endTime?: number;
/** The player volume level. */
volume?: number;
/** The player position in a track. */
position?: number;
/** Whether the player is paused. */
paused?: boolean;
/** The audio effects. */
filters?: object;
/** voice payload. */
voice?: {
token: string;
sessionId: string;
endpoint: string;
};
/** Whether to not replace the track if a play payload is sent. */
noReplace?: boolean;
};
}
export {};