@discordeno/gateway 19.0.0-next.fe00a6f → 19.0.0-next.ffdef6c
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/README.md +16 -13
- package/dist/cjs/Shard.cjs +649 -0
- package/dist/cjs/index.cjs +22 -0
- package/dist/cjs/manager.cjs +503 -0
- package/dist/cjs/types.cjs +64 -0
- package/dist/esm/Shard.js +585 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/manager.js +488 -0
- package/dist/esm/types.js +43 -0
- package/dist/{Shard.d.ts → types/Shard.d.ts} +43 -95
- package/dist/types/Shard.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{manager.d.ts → types/manager.d.ts} +111 -12
- package/dist/types/manager.d.ts.map +1 -0
- package/dist/{types.d.ts → types/types.d.ts} +39 -5
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +35 -28
- package/dist/Shard.d.ts.map +0 -1
- package/dist/Shard.js +0 -615
- package/dist/Shard.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -243
- package/dist/manager.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -23
- package/dist/types.js.map +0 -1
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export var ShardState = /*#__PURE__*/ function(ShardState) {
|
|
2
|
+
/** Shard is fully connected to the gateway and receiving events from Discord. */ ShardState[ShardState["Connected"] = 0] = "Connected";
|
|
3
|
+
/** Shard started to connect to the gateway. This is only used if the shard is not currently trying to identify or resume. */ ShardState[ShardState["Connecting"] = 1] = "Connecting";
|
|
4
|
+
/** Shard got disconnected and reconnection actions have been started. */ ShardState[ShardState["Disconnected"] = 2] = "Disconnected";
|
|
5
|
+
/** The shard is connected to the gateway but only heartbeating. At this state the shard has not been identified with discord. */ ShardState[ShardState["Unidentified"] = 3] = "Unidentified";
|
|
6
|
+
/** Shard is trying to identify with the gateway to create a new session. */ ShardState[ShardState["Identifying"] = 4] = "Identifying";
|
|
7
|
+
/** Shard is trying to resume a session with the gateway. */ ShardState[ShardState["Resuming"] = 5] = "Resuming";
|
|
8
|
+
/** Shard got shut down studied or due to a not (self) fixable error and may not attempt to reconnect on its own. */ ShardState[ShardState["Offline"] = 6] = "Offline";
|
|
9
|
+
return ShardState;
|
|
10
|
+
}({});
|
|
11
|
+
export var TransportCompression = /*#__PURE__*/ function(TransportCompression) {
|
|
12
|
+
/**
|
|
13
|
+
* ZLib-Stream Transport Compression.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Uses `node:zlib` to decompress the payloads
|
|
17
|
+
*
|
|
18
|
+
* @see https://discord.com/developers/docs/topics/gateway#zlibstream
|
|
19
|
+
*/ TransportCompression["zlib"] = "zlib-stream";
|
|
20
|
+
/**
|
|
21
|
+
* ZStd-Stream Transport Compression.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Uses `fzstd` to decompress the payloads. `fzstd` is an optional dependency, it is required to be installed for this compression.
|
|
25
|
+
*
|
|
26
|
+
* @see https://discord.com/developers/docs/topics/gateway#zstdstream
|
|
27
|
+
*/ TransportCompression["zstd"] = "zstd-stream";
|
|
28
|
+
return TransportCompression;
|
|
29
|
+
}({});
|
|
30
|
+
export var ShardSocketCloseCodes = /*#__PURE__*/ function(ShardSocketCloseCodes) {
|
|
31
|
+
/** A regular Shard shutdown. */ ShardSocketCloseCodes[ShardSocketCloseCodes["Shutdown"] = 3000] = "Shutdown";
|
|
32
|
+
/** A resume has been requested and therefore the old connection needs to be closed. */ ShardSocketCloseCodes[ShardSocketCloseCodes["ResumeClosingOldConnection"] = 3024] = "ResumeClosingOldConnection";
|
|
33
|
+
/**
|
|
34
|
+
* Did not receive a heartbeat ACK in time.
|
|
35
|
+
* Closing the shard and creating a new session.
|
|
36
|
+
*/ ShardSocketCloseCodes[ShardSocketCloseCodes["ZombiedConnection"] = 3010] = "ZombiedConnection";
|
|
37
|
+
/** Discordeno's gateway tests hae been finished, therefore the Shard can be turned off. */ ShardSocketCloseCodes[ShardSocketCloseCodes["TestingFinished"] = 3064] = "TestingFinished";
|
|
38
|
+
/** Special close code reserved for Discordeno's zero-downtime resharding system. */ ShardSocketCloseCodes[ShardSocketCloseCodes["Resharded"] = 3065] = "Resharded";
|
|
39
|
+
/** Shard is re-identifying therefore the old connection needs to be closed. */ ShardSocketCloseCodes[ShardSocketCloseCodes["ReIdentifying"] = 3066] = "ReIdentifying";
|
|
40
|
+
return ShardSocketCloseCodes;
|
|
41
|
+
}({});
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IEFjdGl2aXR5VHlwZXMsIENhbWVsaXplLCBEaXNjb3JkQWN0aXZpdHksIERpc2NvcmRHYXRld2F5UGF5bG9hZCwgR2F0ZXdheU9wY29kZXMsIFByZXNlbmNlU3RhdHVzIH0gZnJvbSAnQGRpc2NvcmRlbm8vdHlwZXMnXG5pbXBvcnQgdHlwZSBTaGFyZCBmcm9tICcuL1NoYXJkLmpzJ1xuXG5leHBvcnQgZW51bSBTaGFyZFN0YXRlIHtcbiAgLyoqIFNoYXJkIGlzIGZ1bGx5IGNvbm5lY3RlZCB0byB0aGUgZ2F0ZXdheSBhbmQgcmVjZWl2aW5nIGV2ZW50cyBmcm9tIERpc2NvcmQuICovXG4gIENvbm5lY3RlZCA9IDAsXG4gIC8qKiBTaGFyZCBzdGFydGVkIHRvIGNvbm5lY3QgdG8gdGhlIGdhdGV3YXkuIFRoaXMgaXMgb25seSB1c2VkIGlmIHRoZSBzaGFyZCBpcyBub3QgY3VycmVudGx5IHRyeWluZyB0byBp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bGVhbjtcbn1cbiJdLCJuYW1lcyI6WyJTaGFyZFN0YXRlIiwiVHJhbnNwb3J0Q29tcHJlc3Npb24iLCJTaGFyZFNvY2tldENsb3NlQ29kZXMiXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sSUFBQSxBQUFLQSxvQ0FBQUE7SUFDViwrRUFBK0U7SUFFL0UsMkhBQTJIO0lBRTNILHVFQUF1RTtJQUV2RSwrSEFBK0g7SUFFL0gsMEVBQTBFO0lBRTFFLDBEQUEwRDtJQUUxRCxrSEFBa0g7V0FieEdBO01BZVg7QUFFRCxPQUFPLElBQUEsQUFBS0MsOENBQUFBO0lBQ1Y7Ozs7Ozs7R0FPQztJQUVEOzs7Ozs7O0dBT0M7V0FqQlNBO01BbUJYO0FBaUhELE9BQU8sSUFBQSxBQUFLQywrQ0FBQUE7SUFDViw4QkFBOEI7SUFFOUIscUZBQXFGO0lBRXJGOzs7R0FHQztJQUVELHlGQUF5RjtJQUV6RixrRkFBa0Y7SUFFbEYsNkVBQTZFO1dBZG5FQTtNQWdCWCJ9
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
import { ShardState } from './types.js';
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { type Inflate } from 'node:zlib';
|
|
3
|
+
import type { DiscordGatewayPayload } from '@discordeno/types';
|
|
4
|
+
import { LeakyBucket, logger } from '@discordeno/utils';
|
|
5
|
+
import type { Decompress as ZstdDecompress } from 'fzstd';
|
|
6
|
+
import { type BotStatusUpdate, type ShardEvents, type ShardGatewayConfig, type ShardHeart, type ShardSocketRequest, ShardState } from './types.js';
|
|
7
7
|
export declare class DiscordenoShard {
|
|
8
8
|
/** The id of the shard */
|
|
9
9
|
id: number;
|
|
@@ -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?: WebSocket;
|
|
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. */
|
|
@@ -28,27 +28,27 @@ export declare class DiscordenoShard {
|
|
|
28
28
|
/** The shard related event handlers. */
|
|
29
29
|
events: ShardEvents;
|
|
30
30
|
/** Cache for pending gateway requests which should have been send while the gateway went offline. */
|
|
31
|
-
offlineSendQueue:
|
|
31
|
+
offlineSendQueue: (() => void)[];
|
|
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
35
|
bucket: LeakyBucket;
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
/** Logger for the bucket */
|
|
37
|
+
logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
|
38
|
+
/** Text decoder used for compressed payloads */
|
|
39
|
+
textDecoder: TextDecoder;
|
|
40
|
+
/** ZLib Inflate instance for ZLib-stream transport payloads */
|
|
41
|
+
inflate?: Inflate;
|
|
42
|
+
/** ZLib inflate buffer */
|
|
43
|
+
inflateBuffer: Uint8Array | null;
|
|
44
|
+
/** ZStd Decompress instance for ZStd-stream transport payloads */
|
|
45
|
+
zstdDecompress?: ZstdDecompress;
|
|
46
|
+
/** Queue for compressed payloads for Zstd Decompress */
|
|
47
|
+
decompressionPromisesQueue: ((data: DiscordGatewayPayload) => void)[];
|
|
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.
|
|
51
|
+
/** The url to connect to. Initially this is the discord gateway url, and then is switched to resume gateway url once a READY is received. */
|
|
52
52
|
get connectionUrl(): string;
|
|
53
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. */
|
|
54
54
|
calculateSafeRequests(): number;
|
|
@@ -63,26 +63,38 @@ export declare class DiscordenoShard {
|
|
|
63
63
|
isOpen(): boolean;
|
|
64
64
|
/** Attempt to resume the previous shards session with the gateway. */
|
|
65
65
|
resume(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
66
|
+
/**
|
|
67
|
+
* Send a message to Discord.
|
|
68
|
+
* @param highPriority - Whether this message should be send asap.
|
|
68
69
|
*/
|
|
69
70
|
send(message: ShardSocketRequest, highPriority?: boolean): Promise<void>;
|
|
70
71
|
/** Shutdown the this. Forcefully disconnect the shard from Discord. The shard may not attempt to reconnect with Discord. */
|
|
71
72
|
shutdown(): Promise<void>;
|
|
73
|
+
/** Handle a gateway connection error */
|
|
74
|
+
handleError(error: Event): void;
|
|
72
75
|
/** Handle a gateway connection close. */
|
|
73
|
-
handleClose(close:
|
|
76
|
+
handleClose(close: CloseEvent): Promise<void>;
|
|
77
|
+
/** Handle an incoming gateway message. */
|
|
78
|
+
handleMessage(message: MessageEvent): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Decompress a zlib/zstd compressed packet
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
decompressPacket(data: ArrayBuffer | Buffer): Promise<DiscordGatewayPayload | null>;
|
|
74
85
|
/** Handles a incoming gateway packet. */
|
|
75
86
|
handleDiscordPacket(packet: DiscordGatewayPayload): Promise<void>;
|
|
76
87
|
forwardToBot(packet: DiscordGatewayPayload): void;
|
|
77
|
-
/** Handle an incoming gateway message. */
|
|
78
|
-
handleMessage(message: NodeWebSocket.MessageEvent): Promise<void>;
|
|
79
88
|
/**
|
|
80
89
|
* Override in order to make the shards presence.
|
|
81
90
|
* async in case devs create the presence based on eg. database values.
|
|
82
91
|
* Passing the shard's id there to make it easier for the dev to use this function.
|
|
83
92
|
*/
|
|
84
93
|
makePresence(): Promise<BotStatusUpdate | undefined>;
|
|
85
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* This function communicates with the management process, in order to know whether its free to identify.
|
|
96
|
+
* When this function resolves, this means that the shard is allowed to send an identify payload to discord.
|
|
97
|
+
*/
|
|
86
98
|
requestIdentify(): Promise<void>;
|
|
87
99
|
/** This function communicates with the management process, in order to tell it can identify the next shard. */
|
|
88
100
|
shardIsReady(): Promise<void>;
|
|
@@ -90,74 +102,6 @@ export declare class DiscordenoShard {
|
|
|
90
102
|
startHeartbeating(interval: number): void;
|
|
91
103
|
/** Stop the heartbeating process with discord. */
|
|
92
104
|
stopHeartbeating(): void;
|
|
93
|
-
/**
|
|
94
|
-
* Connects the bot user to a voice or stage channel.
|
|
95
|
-
*
|
|
96
|
-
* This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
|
|
97
|
-
*
|
|
98
|
-
* @param guildId - The ID of the guild the voice channel to leave is in.
|
|
99
|
-
* @param channelId - The ID of the channel you want to join.
|
|
100
|
-
*
|
|
101
|
-
* @remarks
|
|
102
|
-
* Requires the `CONNECT` permission.
|
|
103
|
-
*
|
|
104
|
-
* Fires a _Voice State Update_ gateway event.
|
|
105
|
-
*
|
|
106
|
-
* @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
|
|
107
|
-
*/
|
|
108
|
-
joinVoiceChannel(guildId: BigString, channelId: BigString, options?: AtLeastOne<Omit<UpdateVoiceState, 'guildId' | 'channelId'>>): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* Edits the bot status in all shards that this gateway manages.
|
|
111
|
-
*
|
|
112
|
-
* @param data The status data to set the bots status to.
|
|
113
|
-
* @returns Promise<void>
|
|
114
|
-
*/
|
|
115
|
-
editBotStatus(data: StatusUpdate): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Edits the bot's status on one shard.
|
|
118
|
-
*
|
|
119
|
-
* @param shardId The shard id to edit the status for.
|
|
120
|
-
* @param data The status data to set the bots status to.
|
|
121
|
-
* @returns Promise<void>
|
|
122
|
-
*/
|
|
123
|
-
editShardStatus(data: StatusUpdate): Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Fetches the list of members for a guild over the gateway.
|
|
126
|
-
*
|
|
127
|
-
* @param guildId - The ID of the guild to get the list of members for.
|
|
128
|
-
* @param options - The parameters for the fetching of the members.
|
|
129
|
-
*
|
|
130
|
-
* @remarks
|
|
131
|
-
* If requesting the entire member list:
|
|
132
|
-
* - Requires the `GUILD_MEMBERS` intent.
|
|
133
|
-
*
|
|
134
|
-
* If requesting presences ({@link RequestGuildMembers.presences | presences} set to `true`):
|
|
135
|
-
* - Requires the `GUILD_PRESENCES` intent.
|
|
136
|
-
*
|
|
137
|
-
* If requesting a prefix ({@link RequestGuildMembers.query | query} non-`undefined`):
|
|
138
|
-
* - Returns a maximum of 100 members.
|
|
139
|
-
*
|
|
140
|
-
* If requesting a users by ID ({@link RequestGuildMembers.userIds | userIds} non-`undefined`):
|
|
141
|
-
* - Returns a maximum of 100 members.
|
|
142
|
-
*
|
|
143
|
-
* Fires a _Guild Members Chunk_ gateway event for every 1000 members fetched.
|
|
144
|
-
*
|
|
145
|
-
* @see {@link https://discord.com/developers/docs/topics/gateway#request-guild-members}
|
|
146
|
-
*/
|
|
147
|
-
requestMembers(guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>): Promise<Camelize<DiscordMember[]>>;
|
|
148
|
-
/**
|
|
149
|
-
* Leaves the voice channel the bot user is currently in.
|
|
150
|
-
*
|
|
151
|
-
* This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
|
|
152
|
-
*
|
|
153
|
-
* @param guildId - The ID of the guild the voice channel to leave is in.
|
|
154
|
-
*
|
|
155
|
-
* @remarks
|
|
156
|
-
* Fires a _Voice State Update_ gateway event.
|
|
157
|
-
*
|
|
158
|
-
* @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
|
|
159
|
-
*/
|
|
160
|
-
leaveVoiceChannel(guildId: BigString): Promise<void>;
|
|
161
105
|
}
|
|
162
106
|
export interface ShardCreateOptions {
|
|
163
107
|
/** The shard id */
|
|
@@ -166,10 +110,14 @@ export interface ShardCreateOptions {
|
|
|
166
110
|
connection: ShardGatewayConfig;
|
|
167
111
|
/** The event handlers for events on the shard. */
|
|
168
112
|
events: ShardEvents;
|
|
113
|
+
/** The logger for the shard */
|
|
114
|
+
logger?: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
|
169
115
|
/** The handler to request a space to make an identify request. */
|
|
170
116
|
requestIdentify?: () => Promise<void>;
|
|
171
117
|
/** The handler to alert the gateway manager that this shard has received a READY event. */
|
|
172
118
|
shardIsReady?: () => Promise<void>;
|
|
119
|
+
/** Function to create the bot status to send on Identify requests */
|
|
120
|
+
makePresence?: () => Promise<BotStatusUpdate | undefined>;
|
|
173
121
|
}
|
|
174
122
|
export default DiscordenoShard;
|
|
175
123
|
//# sourceMappingURL=Shard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../../src/Shard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,OAAO,EAA0D,MAAM,WAAW,CAAA;AAChG,OAAO,KAAK,EAAE,qBAAqB,EAA8B,MAAM,mBAAmB,CAAA;AAE1F,OAAO,EAAE,WAAW,EAAmB,MAAM,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,OAAO,CAAA;AAEzD,OAAO,EACL,KAAK,eAA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AMjD;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAI1D;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtC,+GAA+G;IACzG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAEnC,4EAA4E;IAC5E,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IA4EzC,kDAAkD;IAClD,gBAAgB,IAAI,IAAI;CAOzB;AAaD,MAAM,WAAW,kBAAkB;IACjC,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,6BAA6B;IAC7B,UAAU,EAAE,kBAAkB,CAAA;IAC9B,kDAAkD;IAClD,MAAM,EAAE,WAAW,CAAA;IACnB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAA;IAC3E,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAClC,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAA;CAC1D;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { Collection } from '@discordeno/utils';
|
|
1
|
+
import { type AtLeastOne, type BigString, type Camelize, type DiscordGetGatewayBot, type DiscordMemberWithUser, type RequestGuildMembers } from '@discordeno/types';
|
|
2
|
+
import { Collection, logger } from '@discordeno/utils';
|
|
3
3
|
import Shard from './Shard.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type BotStatusUpdate, type ShardEvents, type ShardSocketRequest, type StatusUpdate, type TransportCompression, type UpdateVoiceState } from './types.js';
|
|
5
5
|
export declare function createGatewayManager(options: CreateGatewayManagerOptions): GatewayManager;
|
|
6
6
|
export interface CreateGatewayManagerOptions {
|
|
7
7
|
/**
|
|
@@ -46,6 +46,8 @@ export interface CreateGatewayManagerOptions {
|
|
|
46
46
|
* @default false
|
|
47
47
|
*/
|
|
48
48
|
compress?: boolean;
|
|
49
|
+
/** What transport compression should be used */
|
|
50
|
+
transportCompression?: TransportCompression | null;
|
|
49
51
|
/** The calculated intent value of the events which the shard should receive.
|
|
50
52
|
*
|
|
51
53
|
* @default 0
|
|
@@ -82,7 +84,7 @@ export interface CreateGatewayManagerOptions {
|
|
|
82
84
|
*/
|
|
83
85
|
version?: number;
|
|
84
86
|
/** The events handlers */
|
|
85
|
-
events
|
|
87
|
+
events?: ShardEvents;
|
|
86
88
|
/** This managers cache related settings. */
|
|
87
89
|
cache?: {
|
|
88
90
|
requestMembers?: {
|
|
@@ -91,10 +93,47 @@ export interface CreateGatewayManagerOptions {
|
|
|
91
93
|
* @default false
|
|
92
94
|
*/
|
|
93
95
|
enabled?: boolean;
|
|
94
|
-
/** The pending requests. */
|
|
95
|
-
pending: Collection<string, RequestMemberRequest>;
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* The logger that the gateway manager will use.
|
|
100
|
+
* @default logger // The logger exported by `@discordeno/utils`
|
|
101
|
+
*/
|
|
102
|
+
logger?: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
|
103
|
+
/**
|
|
104
|
+
* Make the presence for when the bot connects to the gateway
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* This function will be called each time a Shard is going to identify
|
|
108
|
+
*/
|
|
109
|
+
makePresence?: () => Promise<BotStatusUpdate | undefined>;
|
|
110
|
+
/** Options related to resharding. */
|
|
111
|
+
resharding?: {
|
|
112
|
+
/**
|
|
113
|
+
* Whether or not automated resharding should be enabled.
|
|
114
|
+
* @default true
|
|
115
|
+
*/
|
|
116
|
+
enabled: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The % of how full a shard is when resharding should be triggered.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* We use discord recommended shard value to get an **approximation** of the shard full percentage to compare with this value so the bot may not reshard at the exact percentage provided but may reshard when it is a bit higher than the provided percentage.
|
|
122
|
+
* For accurate calculation, you may override the `checkIfReshardingIsNeeded` function
|
|
123
|
+
*
|
|
124
|
+
* @default 80 as in 80%
|
|
125
|
+
*/
|
|
126
|
+
shardsFullPercentage: number;
|
|
127
|
+
/**
|
|
128
|
+
* The interval in milliseconds, of how often to check whether resharding is needed and reshard automatically. Set to -1 to disable auto resharding.
|
|
129
|
+
* @default 28800000 (8 hours)
|
|
130
|
+
*/
|
|
131
|
+
checkInterval: number;
|
|
132
|
+
/** Handler to get shard count and other session info. */
|
|
133
|
+
getSessionInfo?: () => Promise<Camelize<DiscordGetGatewayBot>>;
|
|
134
|
+
/** Handler to edit the shard id on any cached guilds. */
|
|
135
|
+
updateGuildsShardId?: (guildIds: string[], shardId: number) => Promise<void>;
|
|
136
|
+
};
|
|
98
137
|
}
|
|
99
138
|
export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
100
139
|
/** The max concurrency buckets. Those will be created when the `spawnShards` (which calls `prepareBuckets` under the hood) function gets called. */
|
|
@@ -108,6 +147,33 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
108
147
|
}>;
|
|
109
148
|
/** The shards that are created. */
|
|
110
149
|
shards: Map<number, Shard>;
|
|
150
|
+
/** The logger for the gateway manager. */
|
|
151
|
+
logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
|
152
|
+
/** Everything related to resharding. */
|
|
153
|
+
resharding: CreateGatewayManagerOptions['resharding'] & {
|
|
154
|
+
/**
|
|
155
|
+
* The interval id of the check interval. This is used to clear the interval when the manager is shutdown.
|
|
156
|
+
*/
|
|
157
|
+
checkIntervalId?: NodeJS.Timeout | undefined;
|
|
158
|
+
/** Holds the shards that resharding has created. Once resharding is done, this replaces the gateway.shards */
|
|
159
|
+
shards: Collection<number, Shard>;
|
|
160
|
+
/** Holds the pending shards that have been created and are pending all shards finish loading. */
|
|
161
|
+
pendingShards: Collection<number, Shard>;
|
|
162
|
+
/** Handler to check if resharding is necessary. */
|
|
163
|
+
checkIfReshardingIsNeeded: () => Promise<{
|
|
164
|
+
needed: boolean;
|
|
165
|
+
info?: Camelize<DiscordGetGatewayBot>;
|
|
166
|
+
}>;
|
|
167
|
+
/** Handler to begin resharding. */
|
|
168
|
+
reshard: (info: Camelize<DiscordGetGatewayBot> & {
|
|
169
|
+
firstShardId?: number;
|
|
170
|
+
lastShardId?: number;
|
|
171
|
+
}) => Promise<void>;
|
|
172
|
+
/** Handler to communicate to a worker that a shard needs to be created. */
|
|
173
|
+
tellWorkerToPrepare: (workerId: number, shardId: number, bucketId: number) => Promise<void>;
|
|
174
|
+
/** Handler to alert the gateway that a shard(resharded) is online. It should now wait for all shards to be pending before shutting off old shards. */
|
|
175
|
+
shardIsPending: (shard: Shard) => Promise<void>;
|
|
176
|
+
};
|
|
111
177
|
/** Determine max number of shards to use based upon the max concurrency. */
|
|
112
178
|
calculateTotalShards: () => number;
|
|
113
179
|
/** Determine the id of the worker which is handling a shard. */
|
|
@@ -117,7 +183,8 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
117
183
|
/** Start identifying all the shards. */
|
|
118
184
|
spawnShards: () => Promise<void>;
|
|
119
185
|
/** Shutdown all shards. */
|
|
120
|
-
shutdown: (code: number, reason: string) => Promise<void>;
|
|
186
|
+
shutdown: (code: number, reason: string, clearReshardingInterval?: boolean) => Promise<void>;
|
|
187
|
+
sendPayload: (shardId: number, payload: ShardSocketRequest) => Promise<void>;
|
|
121
188
|
/** Allows users to hook in and change to communicate to different workers across different servers or anything they like. For example using redis pubsub to talk to other servers. */
|
|
122
189
|
tellWorkerToIdentify: (workerId: number, shardId: number, bucketId: number) => Promise<void>;
|
|
123
190
|
/** Tell the manager to identify a Shard. If this Shard is not already managed this will also add the Shard to the manager. */
|
|
@@ -148,7 +215,7 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
148
215
|
* Edits the bot status in all shards that this gateway manages.
|
|
149
216
|
*
|
|
150
217
|
* @param data The status data to set the bots status to.
|
|
151
|
-
* @returns
|
|
218
|
+
* @returns nothing
|
|
152
219
|
*/
|
|
153
220
|
editBotStatus: (data: StatusUpdate) => Promise<void>;
|
|
154
221
|
/**
|
|
@@ -156,7 +223,7 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
156
223
|
*
|
|
157
224
|
* @param shardId The shard id to edit the status for.
|
|
158
225
|
* @param data The status data to set the bots status to.
|
|
159
|
-
* @returns
|
|
226
|
+
* @returns nothing
|
|
160
227
|
*/
|
|
161
228
|
editShardStatus: (shardId: number, data: StatusUpdate) => Promise<void>;
|
|
162
229
|
/**
|
|
@@ -182,7 +249,7 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
182
249
|
*
|
|
183
250
|
* @see {@link https://discord.com/developers/docs/topics/gateway#request-guild-members}
|
|
184
251
|
*/
|
|
185
|
-
requestMembers: (guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>) => Promise<Camelize<
|
|
252
|
+
requestMembers: (guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>) => Promise<Camelize<DiscordMemberWithUser[]>>;
|
|
186
253
|
/**
|
|
187
254
|
* Leaves the voice channel the bot user is currently in.
|
|
188
255
|
*
|
|
@@ -196,13 +263,45 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
196
263
|
* @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
|
|
197
264
|
*/
|
|
198
265
|
leaveVoiceChannel: (guildId: BigString) => Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Used to request soundboard sounds for a list of guilds.
|
|
268
|
+
*
|
|
269
|
+
* This function sends multiple (see remarks) _Request Soundboard Sounds_ gateway command over the gateway behind the scenes.
|
|
270
|
+
*
|
|
271
|
+
* @param guildIds - The guilds to get the sounds from
|
|
272
|
+
*
|
|
273
|
+
* @remarks
|
|
274
|
+
* Fires a _Soundboard Sounds_ gateway event.
|
|
275
|
+
*
|
|
276
|
+
* ⚠️ Discord will send the _Soundboard Sounds_ for each of the guild ids
|
|
277
|
+
* however you may not receive the same number of events as the ids passed to _Request Soundboard Sounds_ for one of the following reasons:
|
|
278
|
+
* - The bot is not in the server provided
|
|
279
|
+
* - The shard the message has been sent from does not receive events for the specified guild
|
|
280
|
+
*
|
|
281
|
+
* To avoid this Discordeno will automatically try to group the ids based on what shard they will need to be sent, but this involves sending multiple messages in multiple shards
|
|
282
|
+
*
|
|
283
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds}
|
|
284
|
+
*/
|
|
285
|
+
requestSoundboardSounds: (guildIds: BigString[]) => Promise<void>;
|
|
286
|
+
/** This managers cache related settings. */
|
|
287
|
+
cache: {
|
|
288
|
+
requestMembers: {
|
|
289
|
+
/**
|
|
290
|
+
* Whether or not request member requests should be cached.
|
|
291
|
+
* @default false
|
|
292
|
+
*/
|
|
293
|
+
enabled: boolean;
|
|
294
|
+
/** The pending requests. */
|
|
295
|
+
pending: Collection<string, RequestMemberRequest>;
|
|
296
|
+
};
|
|
297
|
+
};
|
|
199
298
|
}
|
|
200
299
|
export interface RequestMemberRequest {
|
|
201
300
|
/** The unique nonce for this request. */
|
|
202
301
|
nonce: string;
|
|
203
302
|
/** The resolver handler to run when all members arrive. */
|
|
204
|
-
resolve: (value: Camelize<
|
|
303
|
+
resolve: (value: Camelize<DiscordMemberWithUser[]> | PromiseLike<Camelize<DiscordMemberWithUser[]>>) => void;
|
|
205
304
|
/** The members that have already arrived for this request. */
|
|
206
|
-
members:
|
|
305
|
+
members: DiscordMemberWithUser[];
|
|
207
306
|
}
|
|
208
307
|
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAI1B,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,UAAU,EAAS,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAA;AAEnB,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,cAAc,CAujBzF;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oFAAoF;IACpF,UAAU,CAAC,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAA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AE,MAAM,CAAA;IACb,2DAA2D;IAC3D,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,qBAAqB,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAA;IAC5G,8DAA8D;IAC9D,OAAO,EAAE,qBAAqB,EAAE,CAAA;CACjC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ActivityTypes, Camelize, DiscordActivity, DiscordGatewayPayload, GatewayOpcodes, PresenceStatus } from '@discordeno/types';
|
|
3
2
|
import type Shard from './Shard.js';
|
|
4
3
|
export declare enum ShardState {
|
|
@@ -17,12 +16,46 @@ export declare enum ShardState {
|
|
|
17
16
|
/** Shard got shut down studied or due to a not (self) fixable error and may not attempt to reconnect on its own. */
|
|
18
17
|
Offline = 6
|
|
19
18
|
}
|
|
19
|
+
export declare enum TransportCompression {
|
|
20
|
+
/**
|
|
21
|
+
* ZLib-Stream Transport Compression.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Uses `node:zlib` to decompress the payloads
|
|
25
|
+
*
|
|
26
|
+
* @see https://discord.com/developers/docs/topics/gateway#zlibstream
|
|
27
|
+
*/
|
|
28
|
+
zlib = "zlib-stream",
|
|
29
|
+
/**
|
|
30
|
+
* ZStd-Stream Transport Compression.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Uses `fzstd` to decompress the payloads. `fzstd` is an optional dependency, it is required to be installed for this compression.
|
|
34
|
+
*
|
|
35
|
+
* @see https://discord.com/developers/docs/topics/gateway#zstdstream
|
|
36
|
+
*/
|
|
37
|
+
zstd = "zstd-stream"
|
|
38
|
+
}
|
|
20
39
|
export interface ShardGatewayConfig {
|
|
21
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Whatever to enable Payload compression.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* This is compatible with {@link transportCompression}
|
|
22
45
|
*
|
|
23
46
|
* @default false
|
|
47
|
+
*
|
|
48
|
+
* @see https://discord.com/developers/docs/topics/gateway#payload-compression
|
|
24
49
|
*/
|
|
25
50
|
compress: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* What Transport Compression should be use
|
|
53
|
+
*
|
|
54
|
+
* @default null
|
|
55
|
+
*
|
|
56
|
+
* @see https://discord.com/developers/docs/topics/gateway#transport-compression
|
|
57
|
+
*/
|
|
58
|
+
transportCompression: TransportCompression | null;
|
|
26
59
|
/** The calculated intent value of the events which the shard should receive.
|
|
27
60
|
*
|
|
28
61
|
* @default 0
|
|
@@ -70,7 +103,7 @@ export interface ShardHeart {
|
|
|
70
103
|
/** Interval between heartbeats requested by Discord. */
|
|
71
104
|
interval: number;
|
|
72
105
|
/** Id of the interval, which is used for sending the heartbeats. */
|
|
73
|
-
intervalId?: NodeJS.
|
|
106
|
+
intervalId?: NodeJS.Timeout;
|
|
74
107
|
/** Unix (in milliseconds) timestamp when the last heartbeat ACK was received from Discord. */
|
|
75
108
|
lastAck?: number;
|
|
76
109
|
/** Unix timestamp (in milliseconds) when the last heartbeat was sent. */
|
|
@@ -116,7 +149,8 @@ export declare enum ShardSocketCloseCodes {
|
|
|
116
149
|
Shutdown = 3000,
|
|
117
150
|
/** A resume has been requested and therefore the old connection needs to be closed. */
|
|
118
151
|
ResumeClosingOldConnection = 3024,
|
|
119
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Did not receive a heartbeat ACK in time.
|
|
120
154
|
* Closing the shard and creating a new session.
|
|
121
155
|
*/
|
|
122
156
|
ZombiedConnection = 3010,
|
|
@@ -161,7 +195,7 @@ export interface UpdateVoiceState {
|
|
|
161
195
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
|
162
196
|
export interface StatusUpdate {
|
|
163
197
|
/** The user's activities */
|
|
164
|
-
activities?: Camelize<
|
|
198
|
+
activities?: Camelize<Omit<DiscordActivity, 'created_at'>[]>;
|
|
165
199
|
/** The user's new status */
|
|
166
200
|
status: keyof typeof PresenceStatus;
|
|
167
201
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACxI,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,oBAAY,UAAU;IACpB,iFAAiF;IACjF,SAAS,IAAI;IACb,6HAA6H;IAC7H,UAAU,IAAI;IACd,yEAAyE;IACzE,YAAY,IAAI;IAChB,iIAAiI;IACjI,YAAY,IAAI;IAChB,4EAA4E;IAC5E,WAAW,IAAI;IACf,4DAA4D;IAC5D,QAAQ,IAAI;IACZ,oHAAoH;IACpH,OAAO,IAAI;CACZ;AAED,oBAAY,oBAAoB;IAC9B;;;;;;;OAOG;IACH,IAAI,gBAAgB;IACpB;;;;;;;OAOG;IACH,IAAI,gBAAgB;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;OASG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;;;OAMG;IACH,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAA;IACjD;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,iCAAiC;IACjC,UAAU,EAAE;QACV;;;WAGG;QACH,EAAE,EAAE,MAAM,CAAA;QACV;;;WAGG;QACH,OAAO,EAAE,MAAM,CAAA;QACf;;;WAGG;QACH,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WA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