mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
src: sharding cleanup and checkReady rewrite (#3393)
* src: Step 1 of who knows how many * src: Remove accidentally committed test file * src: Remove useless added property in package.json * docs: Trailing spaces, come back >.> * src: Buhbye uws, we will miss you..not! * src: Move 'auto' shard selection from totalShardCount to shards * src: tweak * src: Filter out floats from shard IDs You want half of a shard or what? * src: Misc cleanup and bugfix for GUILD_BAN_ADD * src: Rewrite checkReady * src: Misse this while merging master into my branch * typings: Bring these up to date * typings: Forgot allReady event * src: Don't checkReady if the shard isn't waiting for guilds * src: Fix a possible bug for when the ws dies and the session becomes -1 * src: Hopefully fix last edge case that could case a shard to infinitely boot loop * src: Rename totalShardCount to shardCount * src: Small bugfix * src: Correct error message for shardCount being imvalid Co-Authored-By: bdistin <bdistin@gmail.com> * src: Small tweaks * src: If this doesn't fix the issues I'm gonna throw a brick at my PC * src: I swear, STOP BREAKING * src: *groans at a certain snake* * src: Use undefined instead of null on destroy in close event Setting it to null sets the close code to null, which causes a WebSocket error to be thrown. The error is thrown from WebSocket, although there is no connection alive. Fun times! * src: @SpaceEEC's requested changes * src: Remove zucc from discord.js Discord is removing support for it, sooo... Bye bye * src: Missed this * src: Apply @kyranet's suggestions Co-Authored-By: Antonio Román <kyradiscord@gmail.com> * src: @kyranet's suggestions * src: Remove pako, update debug messages - Pako is officially gone from both enviroments Install zlib-sync on node.js if you want it - Improve a few debug messages some more - Discover that internal sharding works in browsers but please don't do that
This commit is contained in:
22
typings/index.d.ts
vendored
22
typings/index.d.ts
vendored
@@ -1650,6 +1650,7 @@ declare module 'discord.js' {
|
||||
|
||||
public on(event: WSEventType, listener: (data: any, shardID: number) => void): this;
|
||||
public once(event: WSEventType, listener: (data: any, shardID: number) => void): this;
|
||||
|
||||
private debug(message: string, shard?: WebSocketShard): void;
|
||||
private connect(): Promise<void>;
|
||||
private createShards(): Promise<void>;
|
||||
@@ -1657,9 +1658,9 @@ declare module 'discord.js' {
|
||||
private broadcast(packet: object): void;
|
||||
private destroy(): void;
|
||||
private _handleSessionLimit(remaining?: number, resetAfter?: number): Promise<void>;
|
||||
private handlePacket(packet?: object, shard?: WebSocketShard): Promise<boolean>;
|
||||
private checkReady(): boolean;
|
||||
private triggerReady(): void;
|
||||
private handlePacket(packet?: object, shard?: WebSocketShard): boolean;
|
||||
private checkShardsReady(): Promise<void>;
|
||||
private triggerClientReady(): void;
|
||||
}
|
||||
|
||||
export class WebSocketShard extends EventEmitter {
|
||||
@@ -1671,14 +1672,15 @@ declare module 'discord.js' {
|
||||
private lastHeartbeatAcked: boolean;
|
||||
private ratelimit: { queue: object[]; total: number; remaining: number; time: 60e3; timer: NodeJS.Timeout | null; };
|
||||
private connection: WebSocket | null;
|
||||
private helloTimeout: NodeJS.Timeout | null;
|
||||
private helloTimeout: NodeJS.Timeout | undefined;
|
||||
private eventsAttached: boolean;
|
||||
private expectedGuilds: Set<Snowflake> | undefined;
|
||||
private readyTimeout: NodeJS.Timeout | undefined;
|
||||
|
||||
public manager: WebSocketManager;
|
||||
public id: number;
|
||||
public status: Status;
|
||||
public pings: [number, number, number];
|
||||
public readonly ping: number;
|
||||
public ping: number;
|
||||
|
||||
private debug(message: string): void;
|
||||
private connect(): Promise<void>;
|
||||
@@ -1687,6 +1689,7 @@ declare module 'discord.js' {
|
||||
private onError(error: ErrorEvent | object): void;
|
||||
private onClose(event: CloseEvent): void;
|
||||
private onPacket(packet: object): void;
|
||||
private checkReady(): void;
|
||||
private setHelloTimeout(time?: number): void;
|
||||
private setHeartbeatTimer(time: number): void;
|
||||
private sendHeartbeat(): void;
|
||||
@@ -1703,12 +1706,14 @@ declare module 'discord.js' {
|
||||
public on(event: 'resumed', listener: () => void): this;
|
||||
public on(event: 'close', listener: (event: CloseEvent) => void): this;
|
||||
public on(event: 'invalidSession', listener: () => void): this;
|
||||
public on(event: 'allReady', listener: (unavailableGuilds?: Set<Snowflake>) => void): this;
|
||||
public on(event: string, listener: Function): this;
|
||||
|
||||
public once(event: 'ready', listener: () => void): this;
|
||||
public once(event: 'resumed', listener: () => void): this;
|
||||
public once(event: 'close', listener: (event: CloseEvent) => void): this;
|
||||
public once(event: 'invalidSession', listener: () => void): this;
|
||||
public once(event: 'allReady', listener: (unavailableGuilds?: Set<Snowflake>) => void): this;
|
||||
public once(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
@@ -2054,9 +2059,8 @@ declare module 'discord.js' {
|
||||
}
|
||||
|
||||
interface ClientOptions {
|
||||
shards?: number | number[];
|
||||
shardCount?: number | 'auto';
|
||||
totalShardCount?: number;
|
||||
shards?: number | number[] | 'auto';
|
||||
shardCount?: number;
|
||||
messageCacheMaxSize?: number;
|
||||
messageCacheLifetime?: number;
|
||||
messageSweepInterval?: number;
|
||||
|
||||
Reference in New Issue
Block a user