class VoiceWebSocket

extends

EventEmitter
export declare class VoiceWebSocket extends EventEmitter

An extension of the WebSocket class to provide helper functionality when interacting with the Discord Voice gateway.

Constructors

constructor(
address: string
debug: boolean
)

Creates a new VoiceWebSocket.

optional
ping? : number

The last recorded ping.

sequence : number

The last sequence number acknowledged from Discord. Will be -1 if no sequence numbered messages have been received.

destroy() : void

Destroys the VoiceWebSocket. The heartbeat interval is cleared, and the connection is closed.

onMessage() : void

Handles message events on the WebSocket. Attempts to JSON parse the messages and emit them as packets.

sendPacket(
packet: any
) : void

Sends a JSON-stringifiable packet over the WebSocket.

setHeartbeatInterval(
ms: number
) : void

Sets/clears an interval to send heartbeats over the WebSocket.

on(
event: 'error'
listener: (error: Error) => void
) : this