mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
refactor(WebSocketManager): use /ws package internally (#9099)
This commit is contained in:
66
packages/discord.js/typings/index.d.ts
vendored
66
packages/discord.js/typings/index.d.ts
vendored
@@ -40,6 +40,7 @@ import {
|
||||
import { Awaitable, JSONEncodable } from '@discordjs/util';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest';
|
||||
import { WebSocketManager as WSWebSocketManager, IShardingStrategy, SessionInfo } from '@discordjs/ws';
|
||||
import {
|
||||
APIActionRowComponent,
|
||||
APIApplicationCommandInteractionData,
|
||||
@@ -3302,11 +3303,8 @@ export class WebhookClient extends WebhookMixin(BaseClient) {
|
||||
|
||||
export class WebSocketManager extends EventEmitter {
|
||||
private constructor(client: Client);
|
||||
private totalShards: number | string;
|
||||
private shardQueue: Set<WebSocketShard>;
|
||||
private readonly packetQueue: unknown[];
|
||||
private destroyed: boolean;
|
||||
private reconnecting: boolean;
|
||||
|
||||
public readonly client: Client;
|
||||
public gateway: string | null;
|
||||
@@ -3317,10 +3315,8 @@ export class WebSocketManager extends EventEmitter {
|
||||
public on(event: GatewayDispatchEvents, listener: (data: any, shardId: number) => void): this;
|
||||
public once(event: GatewayDispatchEvents, listener: (data: any, shardId: number) => void): this;
|
||||
|
||||
private debug(message: string, shard?: WebSocketShard): void;
|
||||
private debug(message: string, shardId?: number): void;
|
||||
private connect(): Promise<void>;
|
||||
private createShards(): Promise<void>;
|
||||
private reconnect(): Promise<void>;
|
||||
private broadcast(packet: unknown): void;
|
||||
private destroy(): void;
|
||||
private handlePacket(packet?: unknown, shard?: WebSocketShard): boolean;
|
||||
@@ -3339,26 +3335,11 @@ export interface WebSocketShardEventTypes {
|
||||
|
||||
export class WebSocketShard extends EventEmitter {
|
||||
private constructor(manager: WebSocketManager, id: number);
|
||||
private sequence: number;
|
||||
private closeSequence: number;
|
||||
private sessionId: string | null;
|
||||
private resumeURL: string | null;
|
||||
private sessionInfo: SessionInfo | null;
|
||||
public lastPingTimestamp: number;
|
||||
private lastHeartbeatAcked: boolean;
|
||||
private readonly ratelimit: {
|
||||
queue: unknown[];
|
||||
total: number;
|
||||
remaining: number;
|
||||
time: 60e3;
|
||||
timer: NodeJS.Timeout | null;
|
||||
};
|
||||
private connection: WebSocket | null;
|
||||
private helloTimeout: NodeJS.Timeout | null;
|
||||
private eventsAttached: boolean;
|
||||
private expectedGuilds: Set<Snowflake> | null;
|
||||
private readyTimeout: NodeJS.Timeout | null;
|
||||
private closeEmitted: boolean;
|
||||
private wsCloseTimeout: NodeJS.Timeout | null;
|
||||
|
||||
public manager: WebSocketManager;
|
||||
public id: number;
|
||||
@@ -3366,27 +3347,10 @@ export class WebSocketShard extends EventEmitter {
|
||||
public ping: number;
|
||||
|
||||
private debug(message: string): void;
|
||||
private connect(): Promise<void>;
|
||||
private onOpen(): void;
|
||||
private onMessage(event: MessageEvent): void;
|
||||
private onError(error: ErrorEvent | unknown): void;
|
||||
private onClose(event: CloseEvent): void;
|
||||
private onPacket(packet: unknown): void;
|
||||
private onReadyPacket(packet: unknown): void;
|
||||
private gotGuild(guildId: Snowflake): void;
|
||||
private checkReady(): void;
|
||||
private setHelloTimeout(time?: number): void;
|
||||
private setWsCloseTimeout(time?: number): void;
|
||||
private setHeartbeatTimer(time: number): void;
|
||||
private sendHeartbeat(): void;
|
||||
private ackHeartbeat(): void;
|
||||
private identify(): void;
|
||||
private identifyNew(): void;
|
||||
private identifyResume(): void;
|
||||
private _send(data: unknown): void;
|
||||
private processQueue(): void;
|
||||
private destroy(destroyOptions?: { closeCode?: number; reset?: boolean; emit?: boolean; log?: boolean }): void;
|
||||
private emitClose(event?: CloseEvent): void;
|
||||
private _cleanupConnection(): void;
|
||||
private _emitDestroyed(): void;
|
||||
|
||||
public send(data: unknown, important?: boolean): void;
|
||||
|
||||
@@ -3509,16 +3473,23 @@ export enum DiscordjsErrorCodes {
|
||||
TokenMissing = 'TokenMissing',
|
||||
ApplicationCommandPermissionsTokenMissing = 'ApplicationCommandPermissionsTokenMissing',
|
||||
|
||||
/** @deprecated */
|
||||
WSCloseRequested = 'WSCloseRequested',
|
||||
/** @deprecated */
|
||||
WSConnectionExists = 'WSConnectionExists',
|
||||
/** @deprecated */
|
||||
WSNotOpen = 'WSNotOpen',
|
||||
ManagerDestroyed = 'ManagerDestroyed',
|
||||
|
||||
BitFieldInvalid = 'BitFieldInvalid',
|
||||
|
||||
/** @deprecated */
|
||||
ShardingInvalid = 'ShardingInvalid',
|
||||
/** @deprecated */
|
||||
ShardingRequired = 'ShardingRequired',
|
||||
/** @deprecated */
|
||||
InvalidIntents = 'InvalidIntents',
|
||||
/** @deprecated */
|
||||
DisallowedIntents = 'DisallowedIntents',
|
||||
ShardingNoShards = 'ShardingNoShards',
|
||||
ShardingInProcess = 'ShardingInProcess',
|
||||
@@ -4874,10 +4845,11 @@ export interface ClientUserEditOptions {
|
||||
}
|
||||
|
||||
export interface CloseEvent {
|
||||
/** @deprecated */
|
||||
wasClean: boolean;
|
||||
code: number;
|
||||
/** @deprecated */
|
||||
reason: string;
|
||||
target: WebSocket;
|
||||
}
|
||||
|
||||
export type CollectorFilter<T extends unknown[]> = (...args: T) => boolean | Promise<boolean>;
|
||||
@@ -6332,15 +6304,8 @@ export interface WebhookMessageCreateOptions extends Omit<MessageCreateOptions,
|
||||
|
||||
export interface WebSocketOptions {
|
||||
large_threshold?: number;
|
||||
compress?: boolean;
|
||||
properties?: WebSocketProperties;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface WebSocketProperties {
|
||||
os?: string;
|
||||
browser?: string;
|
||||
device?: string;
|
||||
buildStrategy?(manager: WSWebSocketManager): IShardingStrategy;
|
||||
}
|
||||
|
||||
export interface WidgetActivity {
|
||||
@@ -6418,3 +6383,4 @@ export * from '@discordjs/builders';
|
||||
export * from '@discordjs/formatters';
|
||||
export * from '@discordjs/rest';
|
||||
export * from '@discordjs/util';
|
||||
export * from '@discordjs/ws';
|
||||
|
||||
Reference in New Issue
Block a user