discord-ws-gateway
Version:
Simple and tiny implementation of Discord's Gateway using web standard APIs
19 lines (16 loc) • 815 B
TypeScript
import { GatewayIdentifyData, GatewayDispatchEvents, GatewayDispatchPayload } from 'discord-api-types/v10';
type DispatchListener<T extends `${GatewayDispatchEvents}`> = (event: Extract<GatewayDispatchPayload, {
t: T;
}>) => any;
declare function createClient(gatewayUrl: string, identity: GatewayIdentifyData): Client;
declare class Client {
#private;
static create: typeof createClient;
socket: WebSocket;
closed: boolean;
constructor(gatewayUrl: string, identity: GatewayIdentifyData);
addEventListener<T extends `${GatewayDispatchEvents}`>(event: T | 'ALL', callback: DispatchListener<T>): this;
removeEventListener<T extends `${GatewayDispatchEvents}`>(event: T | 'ALL', callback: DispatchListener<T>): this;
close(code?: number): void;
}
export { Client, createClient };