UNPKG

lavacord

Version:

A simple by design lavalink wrapper made for any discord library.

107 lines (106 loc) 2.86 kB
import WebSocket from "ws"; import type { Manager } from "./Manager"; import type { LavalinkNodeOptions } from "./Types"; import type { Stats } from "lavalink-types/v4"; /** * The class for handling everything to do with connecting to Lavalink */ export declare class LavalinkNode { manager: Manager; /** * The id of the LavalinkNode so Nodes are better organized */ id: string; /** * The host of the LavalinkNode, this could be a ip or domain. */ host: string; /** * The port of the LavalinkNode */ port: number | string; /** * The interval that the node will try to reconnect to lavalink at in milliseconds */ reconnectInterval: number; /** * The password of the lavalink node */ password: string; /** * The WebSocket instance for this LavalinkNode */ ws: WebSocket | null; /** * The statistics of the LavalinkNode */ stats: Stats; /** * If the LavalinkNode should allow resuming */ resuming: boolean; /** * The resume timeout */ resumeTimeout: number; /** * Extra info attached to your node, not required and is not sent to lavalink, purely for you. */ state?: any; /** * The major version of the LavaLink node as indicated by /version */ version?: number; /** * The session ID sent by LavaLink on connect. Used for some REST routes */ sessionId?: string; /** * The reconnect timeout * @private */ private _reconnect?; private _sessionUpdated; /** * The base of the connection to lavalink * @param manager The manager that created the LavalinkNode * @param options The options of the LavalinkNode {@link LavalinkNodeOptions} */ constructor(manager: Manager, options: LavalinkNodeOptions); /** * Connects the node to Lavalink */ connect(): Promise<WebSocket>; /** * Destroys the connection to the Lavalink Websocket */ destroy(): boolean; /** * Whether or not the node is connected */ get connected(): boolean; /** * A private function for handling the open event from WebSocket */ private onOpen; /** * Private function for handling the message event from WebSocket * @param data The data that came from lavalink */ private onMessage; /** * Private function for handling the error event from WebSocket * @param error WebSocket error */ private onError; /** * Private function for handling the close event from WebSocket * @param code WebSocket close code * @param reason WebSocket close reason */ private onClose; /** * Handles reconnecting if something happens and the node discounnects */ private reconnect; }