Files
discordeno/gateway/shard.ts
T
Skillz4KillzandLTS20050703 a0a1554756 refactor: typings using ReturnType (#2105)
* fix: check new types idea

* fix: type errors

* fix: new style

* fix: more cleanup

* fix: more cleanup

* fix: cleanup audit logs

* fix: cleanup stickers

* fix: cleanup integrations

* fix: more cleanup

* fix: organize into 1 place

* fix: few errors

* fix: some broken import fixes

* fix: quite a lot of fixes across the board

* fix: more fixes for broken imports

* fix: more fixes for broken imports

* fix: handler imports

* fix: all remaining import errors

* fix: more errors needing fixes

* fix: clearing up transformers

* fix: few moer types

* fix: more cleanup of extra types

* fix: fmt

* fix: cleanup discordeno file

* Nuke Base Types (#2102)

* fix: cleanup snake stuff

* convert camelCase to snake_case (#2103)

* fix: add camelize

* fix: finalize remaining errors

* fix: imports in test

Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
2022-03-14 22:11:22 -04:00

51 lines
1.9 KiB
TypeScript

import { GatewayOpcodes } from "../types/shared.ts";
export interface DiscordenoShard {
/** The shard id number. */
id: number;
/** The websocket for this shard. */
ws: WebSocket;
/** The amount of milliseconds to wait between heartbeats. */
resumeInterval: number;
/** The session id important for resuming connections. */
sessionId: string;
/** The previous sequence number, important for resuming connections. */
previousSequenceNumber: number | null;
/** Whether the shard is currently resuming. */
resuming: boolean;
/** Whether the shard has received the ready event. */
ready: boolean;
/** The list of guild ids that are currently unavailable due to an outage. */
unavailableGuildIds: Set<bigint>;
failedToLoadTimeoutId?: number;
heartbeat: {
/** The exact timestamp the last heartbeat was sent. */
lastSentAt: number;
/** The timestamp the last heartbeat ACK was received from discord. */
lastReceivedAt: number;
/** Whether or not the heartbeat was acknowledged by discord in time. */
acknowledged: boolean;
/** Whether or not to keep heartbeating. Useful for when needing to stop heartbeating. */
keepAlive: boolean;
/** The interval between heartbeats requested by discord. */
interval: number;
/** The id of the interval, useful for stopping the interval if ws closed. */
intervalId: number;
};
/** The items/requestst that are in queue to be sent to this shard websocket. */
queue: WebSocketRequest[];
/** Whether or not the queue for this shard is being processed. */
processingQueue: boolean;
/** When the first request for this minute has been sent. */
queueStartedAt: number;
/** The request counter of the queue. */
queueCounter: number;
/** The safe number of requests that can be made while preserving some for required things like heartbeating. */
safeRequestsPerShard: number;
}
export interface WebSocketRequest {
op: GatewayOpcodes;
d: unknown;
}