import type { Client } from './Client'; export class ConnectionProcessor { public get connected() { return this.isConnected; } private isConnected = false; constructor(private readonly client: Client) { } public async onConnect() { this.client.emit('connected'); try { await this.client.initMetaAction(); this.isConnected = true; this.client.emit('ready'); this.client.instances.initUnready(); } catch (e: unknown) { await this.client.adapter.close(); } } public async onDisconnect() { this.isConnected = false; this.client.emit('disconnect'); } public async onClosed(data?: string) { this.isConnected = false; this.client.emit('closed', data); } }