fix(controllers/READY): reimplement guild cache mechanism (#647)

* add lastShardID

* fix ready event controller

* forgot to push this file

* move ready to its own file

* some changes

* Update READY.ts

* some changes idk if they are good

* Update options.ts

* Update READY.ts

* Update guilds.ts
This commit is contained in:
ITOH
2021-03-11 14:09:59 +00:00
committed by GitHub
parent 906fba7763
commit 372dc9988b
7 changed files with 134 additions and 72 deletions
+5 -2
View File
@@ -6,13 +6,12 @@ import {
DiscordPayload,
FetchMembersOptions,
GatewayOpcode,
GatewayStatusUpdatePayload,
ReadyPayload,
} from "../types/mod.ts";
import { Collection } from "../util/collection.ts";
import { delay } from "../util/utils.ts";
import { decompressWith } from "./deps.ts";
import { handleDiscordPayload } from "./shard_manager.ts";
import { Collection } from "../util/collection.ts";
export const basicShards = new Collection<number, BasicShard>();
const heartbeating = new Map<number, boolean>();
@@ -27,6 +26,8 @@ export interface BasicShard {
sessionID: string;
previousSequenceNumber: number | null;
needToResume: boolean;
ready: boolean;
unavailableGuildIDs: Set<string>;
}
interface RequestMemberQueuedRequest {
@@ -53,6 +54,8 @@ export function createShard(
sessionID: oldShard?.sessionID || "",
previousSequenceNumber: oldShard?.previousSequenceNumber || 0,
needToResume: false,
ready: false,
unavailableGuildIDs: new Set<string>(),
};
basicShards.set(basicShard.id, basicShard);