@discordeno/gateway 19.0.0-next.cf121a8 → 19.0.0-next.d0db342
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Shard.d.ts +15 -6
- package/dist/Shard.d.ts.map +1 -1
- package/dist/Shard.js +615 -2
- package/dist/Shard.js.map +1 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -0
- package/dist/manager.d.ts +9 -4
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +243 -2
- package/dist/manager.js.map +1 -0
- package/dist/types.js +23 -2
- package/dist/types.js.map +1 -0
- package/package.json +16 -16
package/dist/Shard.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AtLeastOne, BigString, Camelize, DiscordGatewayPayload, DiscordMember, RequestGuildMembers } from '@discordeno/types';
|
|
2
|
-
import { Collection } from '@discordeno/utils';
|
|
3
|
-
import
|
|
2
|
+
import { Collection, LeakyBucket } from '@discordeno/utils';
|
|
3
|
+
import NodeWebSocket from 'ws';
|
|
4
4
|
import type { RequestMemberRequest } from './manager.js';
|
|
5
5
|
import type { BotStatusUpdate, ShardEvents, ShardGatewayConfig, ShardHeart, ShardSocketRequest, StatusUpdate, UpdateVoiceState } from './types.js';
|
|
6
6
|
import { ShardState } from './types.js';
|
|
@@ -20,7 +20,7 @@ export declare class DiscordenoShard {
|
|
|
20
20
|
/** Current session id of the shard if present. */
|
|
21
21
|
sessionId?: string;
|
|
22
22
|
/** This contains the WebSocket connection to Discord, if currently connected. */
|
|
23
|
-
socket?:
|
|
23
|
+
socket?: NodeWebSocket;
|
|
24
24
|
/** Current internal state of the this. */
|
|
25
25
|
state: ShardState;
|
|
26
26
|
/** The url provided by discord to use when resuming a connection for this this. */
|
|
@@ -32,7 +32,7 @@ export declare class DiscordenoShard {
|
|
|
32
32
|
/** Resolve internal waiting states. Mapped by SelectedEvents => ResolveFunction */
|
|
33
33
|
resolves: Map<"READY" | "RESUMED" | "INVALID_SESSION", (payload: DiscordGatewayPayload) => void>;
|
|
34
34
|
/** Shard bucket. Only access this if you know what you are doing. Bucket for handling shard request rate limits. */
|
|
35
|
-
bucket:
|
|
35
|
+
bucket: LeakyBucket;
|
|
36
36
|
/** This managers cache related settings. */
|
|
37
37
|
cache: {
|
|
38
38
|
requestMembers: {
|
|
@@ -48,6 +48,8 @@ export declare class DiscordenoShard {
|
|
|
48
48
|
constructor(options: ShardCreateOptions);
|
|
49
49
|
/** The gateway configuration which is used to connect to Discord. */
|
|
50
50
|
get gatewayConfig(): ShardGatewayConfig;
|
|
51
|
+
/** The url to connect to. Intially this is the discord gateway url, and then is switched to resume gateway url once a READY is received. */
|
|
52
|
+
get connectionUrl(): string;
|
|
51
53
|
/** Calculate the amount of requests which can safely be made per rate limit interval, before the gateway gets disconnected due to an exceeded rate limit. */
|
|
52
54
|
calculateSafeRequests(): number;
|
|
53
55
|
checkOffline(highPriority: boolean): Promise<void>;
|
|
@@ -68,11 +70,12 @@ export declare class DiscordenoShard {
|
|
|
68
70
|
/** Shutdown the this. Forcefully disconnect the shard from Discord. The shard may not attempt to reconnect with Discord. */
|
|
69
71
|
shutdown(): Promise<void>;
|
|
70
72
|
/** Handle a gateway connection close. */
|
|
71
|
-
handleClose(close:
|
|
73
|
+
handleClose(close: NodeWebSocket.CloseEvent): Promise<void>;
|
|
72
74
|
/** Handles a incoming gateway packet. */
|
|
73
75
|
handleDiscordPacket(packet: DiscordGatewayPayload): Promise<void>;
|
|
76
|
+
forwardToBot(packet: DiscordGatewayPayload): void;
|
|
74
77
|
/** Handle an incoming gateway message. */
|
|
75
|
-
handleMessage(message:
|
|
78
|
+
handleMessage(message: NodeWebSocket.MessageEvent): Promise<void>;
|
|
76
79
|
/**
|
|
77
80
|
* Override in order to make the shards presence.
|
|
78
81
|
* async in case devs create the presence based on eg. database values.
|
|
@@ -81,6 +84,8 @@ export declare class DiscordenoShard {
|
|
|
81
84
|
makePresence(): Promise<BotStatusUpdate | undefined>;
|
|
82
85
|
/** This function communicates with the management process, in order to know whether its free to identify. When this function resolves, this means that the shard is allowed to send an identify payload to discord. */
|
|
83
86
|
requestIdentify(): Promise<void>;
|
|
87
|
+
/** This function communicates with the management process, in order to tell it can identify the next shard. */
|
|
88
|
+
shardIsReady(): Promise<void>;
|
|
84
89
|
/** Start sending heartbeat payloads to Discord in the provided interval. */
|
|
85
90
|
startHeartbeating(interval: number): void;
|
|
86
91
|
/** Stop the heartbeating process with discord. */
|
|
@@ -161,6 +166,10 @@ export interface ShardCreateOptions {
|
|
|
161
166
|
connection: ShardGatewayConfig;
|
|
162
167
|
/** The event handlers for events on the shard. */
|
|
163
168
|
events: ShardEvents;
|
|
169
|
+
/** The handler to request a space to make an identify request. */
|
|
170
|
+
requestIdentify?: () => Promise<void>;
|
|
171
|
+
/** The handler to alert the gateway manager that this shard has received a READY event. */
|
|
172
|
+
shardIsReady?: () => Promise<void>;
|
|
164
173
|
}
|
|
165
174
|
export default DiscordenoShard;
|
|
166
175
|
//# sourceMappingURL=Shard.d.ts.map
|
package/dist/Shard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,qBAAqB,EAErB,aAAa,EAEb,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAA;AAEpF,OAAO,aAAa,MAAM,IAAI,CAAA;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EA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