fix: wrong function call

This commit is contained in:
Yuzu 2022-07-06 20:02:06 -05:00
parent 5471fbb0e1
commit 54b0cb2326
2 changed files with 5 additions and 8 deletions

View File

@ -1 +1 @@
export { deflate as decompressWith } from "../../zlib.js"; export { inflate as decompressWith } from "../../zlib.js";

View File

@ -7,17 +7,14 @@ import { GATEWAY_RATE_LIMIT_RESET_INTERVAL, Shard, ShardState } from "./types.ts
const decoder = new TextDecoder(); const decoder = new TextDecoder();
export async function handleMessage(shard: Shard, message: MessageEvent<any>): Promise<void> { export async function handleMessage(shard: Shard, message_: MessageEvent<any>): Promise<void> {
message = message.data; let message = message_.data;
// If message compression is enabled, // If message compression is enabled,
// Discord might send zlib compressed payloads. // Discord might send zlib compressed payloads.
if (shard.gatewayConfig.compress && message instanceof Blob) { if (shard.gatewayConfig.compress && message instanceof Blob) {
message = decompressWith( message = decoder.decode(decompressWith(new Uint8Array(await message.arrayBuffer())));
new Uint8Array(await message.arrayBuffer()), console.log(message);
0,
(slice: Uint8Array) => decoder.decode(slice),
);
} }
// Safeguard incase decompression failed to make a string. // Safeguard incase decompression failed to make a string.