fix: several small ts errors
This commit is contained in:
parent
b1bdc8cc14
commit
ab3553c52e
1 changed files with 6 additions and 2 deletions
|
@ -1,9 +1,9 @@
|
|||
import zlib from 'fast-zlib';
|
||||
import WebSocket from 'ws';
|
||||
|
||||
import type { Client } from '../client/client';
|
||||
import type { IGatewayMessage } from '../utils/types';
|
||||
|
||||
|
||||
export class GatewayClient {
|
||||
public client: Client;
|
||||
public connection: WebSocket | null;
|
||||
|
@ -38,7 +38,11 @@ export class GatewayClient {
|
|||
this.connection.on('message', async (msg: Buffer | string) => {
|
||||
let parsedMessage: IGatewayMessage<null>;
|
||||
|
||||
if (this.client.options.ws.compression) parsedMessage = this.inflate.process(msg);
|
||||
if (this.client.options.ws.compression && typeof msg === 'object') parsedMessage = JSON.parse(this.inflate.process(msg).toString('utf8'));
|
||||
else if (!this.client.options.ws.compression && typeof msg === 'string') parsedMessage = JSON.parse(msg);
|
||||
else parsedMessage = JSON.parse(msg.toString('utf8'));
|
||||
|
||||
if (parsedMessage.s) this._sequence = parsedMessage.s;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue