seyfert 2.1.0 → 2.1.1-dev-11316886063.0
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/lib/api/Router.d.ts +2 -2
- package/lib/api/Router.js +2 -1
- package/lib/api/Routes/applications.d.ts +29 -30
- package/lib/api/Routes/cdn.d.ts +6 -1
- package/lib/api/Routes/channels.d.ts +44 -45
- package/lib/api/Routes/gateway.d.ts +3 -4
- package/lib/api/Routes/guilds.d.ts +81 -80
- package/lib/api/Routes/index.d.ts +3 -1
- package/lib/api/Routes/interactions.d.ts +6 -6
- package/lib/api/Routes/invites.d.ts +3 -4
- package/lib/api/Routes/skus.d.ts +4 -5
- package/lib/api/Routes/soundboard.d.ts +23 -0
- package/lib/api/Routes/soundboard.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +5 -6
- package/lib/api/Routes/stickers.d.ts +3 -4
- package/lib/api/Routes/users.d.ts +11 -12
- package/lib/api/Routes/voice.d.ts +2 -3
- package/lib/api/Routes/webhooks.d.ts +16 -15
- package/lib/api/api.d.ts +17 -11
- package/lib/api/api.js +12 -10
- package/lib/api/shared.d.ts +1 -1
- package/lib/api/utils/constants.d.ts +2 -0
- package/lib/api/utils/constants.js +2 -1
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/Attachment.d.ts +2 -2
- package/lib/builders/Attachment.js +1 -1
- package/lib/builders/Button.d.ts +1 -1
- package/lib/builders/Button.js +1 -1
- package/lib/builders/Embed.d.ts +1 -1
- package/lib/builders/Embed.js +2 -2
- package/lib/builders/Modal.d.ts +1 -1
- package/lib/builders/Poll.d.ts +1 -1
- package/lib/builders/Poll.js +1 -1
- package/lib/builders/SelectMenu.d.ts +1 -1
- package/lib/builders/SelectMenu.js +1 -1
- package/lib/builders/types.d.ts +2 -1
- package/lib/cache/adapters/default.js +5 -3
- package/lib/cache/adapters/limited.d.ts +1 -2
- package/lib/cache/adapters/limited.js +34 -30
- package/lib/cache/adapters/workeradapter.js +3 -1
- package/lib/cache/index.d.ts +8 -11
- package/lib/cache/index.js +38 -37
- package/lib/cache/resources/bans.d.ts +2 -2
- package/lib/cache/resources/bans.js +1 -1
- package/lib/cache/resources/channels.d.ts +1 -1
- package/lib/cache/resources/default/guild-related.d.ts +1 -2
- package/lib/cache/resources/emojis.d.ts +2 -2
- package/lib/cache/resources/emojis.js +1 -1
- package/lib/cache/resources/guilds.d.ts +2 -2
- package/lib/cache/resources/guilds.js +7 -11
- package/lib/cache/resources/members.d.ts +2 -2
- package/lib/cache/resources/members.js +1 -1
- package/lib/cache/resources/messages.d.ts +2 -2
- package/lib/cache/resources/messages.js +3 -3
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/roles.d.ts +2 -2
- package/lib/cache/resources/roles.js +1 -1
- package/lib/cache/resources/stickers.d.ts +2 -2
- package/lib/cache/resources/stickers.js +1 -1
- package/lib/cache/resources/users.d.ts +2 -2
- package/lib/cache/resources/users.js +1 -1
- package/lib/cache/resources/voice-states.d.ts +2 -2
- package/lib/cache/resources/voice-states.js +1 -1
- package/lib/client/base.d.ts +9 -14
- package/lib/client/base.js +43 -44
- package/lib/client/client.d.ts +3 -7
- package/lib/client/client.js +24 -41
- package/lib/client/collectors.js +1 -1
- package/lib/client/httpclient.d.ts +1 -1
- package/lib/client/transformers.d.ts +37 -34
- package/lib/client/transformers.js +66 -63
- package/lib/client/workerclient.d.ts +10 -11
- package/lib/client/workerclient.js +180 -75
- package/lib/collection.d.ts +3 -3
- package/lib/commands/applications/chat.d.ts +12 -32
- package/lib/commands/applications/chat.js +5 -6
- package/lib/commands/applications/chatcontext.d.ts +6 -6
- package/lib/commands/applications/chatcontext.js +16 -8
- package/lib/commands/applications/entryPoint.d.ts +1 -1
- package/lib/commands/applications/entrycontext.d.ts +6 -6
- package/lib/commands/applications/entrycontext.js +4 -4
- package/lib/commands/applications/menu.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +5 -5
- package/lib/commands/applications/menucontext.js +6 -6
- package/lib/commands/applications/options.d.ts +104 -28
- package/lib/commands/applications/options.js +4 -4
- package/lib/commands/applications/shared.d.ts +5 -2
- package/lib/commands/basecontext.d.ts +1 -1
- package/lib/commands/decorators.d.ts +10 -10
- package/lib/commands/decorators.js +5 -4
- package/lib/commands/handle.d.ts +9 -9
- package/lib/commands/handle.js +94 -68
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +21 -17
- package/lib/commands/optionresolver.d.ts +4 -4
- package/lib/commands/optionresolver.js +3 -3
- package/lib/common/it/formatter.d.ts +21 -21
- package/lib/common/it/formatter.js +40 -41
- package/lib/common/it/logger.js +1 -1
- package/lib/common/it/utils.d.ts +4 -3
- package/lib/common/it/utils.js +52 -27
- package/lib/common/shorters/application.d.ts +2 -3
- package/lib/common/shorters/application.js +3 -3
- package/lib/common/shorters/bans.js +1 -1
- package/lib/common/shorters/channels.d.ts +3 -3
- package/lib/common/shorters/channels.js +3 -3
- package/lib/common/shorters/emojis.js +4 -4
- package/lib/common/shorters/guilds.d.ts +3 -3
- package/lib/common/shorters/guilds.js +5 -9
- package/lib/common/shorters/interaction.d.ts +3 -3
- package/lib/common/shorters/interaction.js +6 -5
- package/lib/common/shorters/members.d.ts +4 -5
- package/lib/common/shorters/members.js +6 -7
- package/lib/common/shorters/messages.d.ts +1 -1
- package/lib/common/shorters/messages.js +4 -4
- package/lib/common/shorters/reactions.d.ts +1 -1
- package/lib/common/shorters/reactions.js +1 -1
- package/lib/common/shorters/roles.js +1 -1
- package/lib/common/shorters/templates.js +2 -2
- package/lib/common/shorters/threads.d.ts +1 -1
- package/lib/common/shorters/threads.js +17 -11
- package/lib/common/shorters/webhook.d.ts +1 -1
- package/lib/common/shorters/webhook.js +4 -4
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/resolvables.d.ts +1 -1
- package/lib/common/types/util.d.ts +4 -1
- package/lib/common/types/write.d.ts +1 -1
- package/lib/components/BaseComponent.js +1 -1
- package/lib/components/ButtonComponent.d.ts +1 -1
- package/lib/components/componentcommand.d.ts +1 -1
- package/lib/components/componentcontext.d.ts +4 -4
- package/lib/components/componentcontext.js +1 -1
- package/lib/components/handler.d.ts +10 -8
- package/lib/components/handler.js +16 -13
- package/lib/components/index.js +2 -1
- package/lib/components/modalcontext.d.ts +2 -2
- package/lib/components/modalcontext.js +1 -1
- package/lib/deps/mixer.d.ts +1 -1
- package/lib/events/handler.d.ts +5 -5
- package/lib/events/handler.js +66 -16
- package/lib/events/hooks/application_command.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.js +1 -1
- package/lib/events/hooks/channel.d.ts +1 -1
- package/lib/events/hooks/dispatch.d.ts +1 -1
- package/lib/events/hooks/entitlement.d.ts +4 -5
- package/lib/events/hooks/entitlement.js +4 -4
- package/lib/events/hooks/guild.d.ts +3 -3
- package/lib/events/hooks/guild.js +1 -1
- package/lib/events/hooks/index.d.ts +1 -0
- package/lib/events/hooks/index.js +1 -0
- package/lib/events/hooks/integration.d.ts +1 -1
- package/lib/events/hooks/integration.js +1 -1
- package/lib/events/hooks/interactions.d.ts +3 -3
- package/lib/events/hooks/invite.d.ts +1 -1
- package/lib/events/hooks/message.d.ts +3 -3
- package/lib/events/hooks/message.js +1 -1
- package/lib/events/hooks/presence.d.ts +2 -2
- package/lib/events/hooks/soundboard.d.ts +155 -0
- package/lib/events/hooks/soundboard.js +28 -0
- package/lib/events/hooks/stage.d.ts +2 -2
- package/lib/events/hooks/thread.d.ts +2 -2
- package/lib/events/hooks/thread.js +2 -2
- package/lib/events/hooks/typing.d.ts +1 -1
- package/lib/events/hooks/typing.js +1 -1
- package/lib/events/hooks/user.d.ts +2 -2
- package/lib/events/hooks/voice.d.ts +2 -2
- package/lib/events/hooks/voice.js +1 -1
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -5
- package/lib/langs/handler.d.ts +2 -2
- package/lib/structures/Guild.d.ts +7 -4
- package/lib/structures/Guild.js +1 -1
- package/lib/structures/GuildBan.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -5
- package/lib/structures/GuildMember.js +5 -3
- package/lib/structures/GuildRole.d.ts +1 -1
- package/lib/structures/GuildTemplate.d.ts +1 -1
- package/lib/structures/Interaction.d.ts +17 -14
- package/lib/structures/Interaction.js +28 -21
- package/lib/structures/Message.d.ts +4 -7
- package/lib/structures/Message.js +5 -5
- package/lib/structures/Poll.d.ts +3 -3
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/VoiceState.d.ts +2 -1
- package/lib/structures/VoiceState.js +1 -1
- package/lib/structures/Webhook.d.ts +3 -3
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +4 -4
- package/lib/structures/channels.js +6 -5
- package/lib/structures/extra/BitField.d.ts +3 -3
- package/lib/structures/extra/BitField.js +34 -33
- package/lib/structures/extra/DiscordBase.js +1 -1
- package/lib/structures/extra/Permissions.d.ts +2 -0
- package/lib/structures/extra/Permissions.js +21 -0
- package/lib/types/gateway.d.ts +53 -5
- package/lib/types/payloads/_interactions/base.d.ts +1 -1
- package/lib/types/payloads/channel.d.ts +2 -2
- package/lib/types/payloads/guild.d.ts +9 -1
- package/lib/types/payloads/guild.js +8 -0
- package/lib/types/payloads/index.d.ts +1 -0
- package/lib/types/payloads/index.js +1 -0
- package/lib/types/payloads/soundboard.d.ts +23 -0
- package/lib/types/payloads/soundboard.js +5 -0
- package/lib/types/payloads/user.js +0 -1
- package/lib/types/rest/application.d.ts +3 -3
- package/lib/types/rest/auditLog.d.ts +1 -1
- package/lib/types/rest/channel.d.ts +2 -2
- package/lib/types/rest/guild.d.ts +2 -2
- package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
- package/lib/types/rest/index.d.ts +1 -0
- package/lib/types/rest/index.js +1 -0
- package/lib/types/rest/oauth2.d.ts +1 -1
- package/lib/types/rest/poll.d.ts +1 -1
- package/lib/types/rest/soundboard.d.ts +64 -0
- package/lib/types/rest/soundboard.js +2 -0
- package/lib/types/rest/stageInstance.d.ts +1 -1
- package/lib/types/rest/template.d.ts +1 -1
- package/lib/types/rest/user.d.ts +1 -1
- package/lib/types/rest/webhook.d.ts +1 -1
- package/lib/types/utils/index.d.ts +11 -2
- package/lib/types/utils/index.js +10 -2
- package/lib/websocket/SharedTypes.d.ts +11 -2
- package/lib/websocket/constants/index.js +0 -10
- package/lib/websocket/discord/basesocket.d.ts +1 -1
- package/lib/websocket/discord/shard.d.ts +1 -1
- package/lib/websocket/discord/shard.js +25 -16
- package/lib/websocket/discord/sharder.d.ts +9 -6
- package/lib/websocket/discord/sharder.js +91 -74
- package/lib/websocket/discord/shared.d.ts +3 -14
- package/lib/websocket/discord/socket/custom.js +19 -6
- package/lib/websocket/discord/worker.d.ts +8 -2
- package/lib/websocket/discord/workermanager.d.ts +42 -17
- package/lib/websocket/discord/workermanager.js +144 -37
- package/lib/websocket/structures/timeout.d.ts +4 -5
- package/lib/websocket/structures/timeout.js +23 -24
- package/package.json +72 -70
- package/lib/cache/resources/threads.d.ts +0 -14
- package/lib/cache/resources/threads.js +0 -32
|
@@ -167,7 +167,11 @@ export declare enum GatewayOpcodes {
|
|
|
167
167
|
/**
|
|
168
168
|
* Sent in response to receiving a heartbeat to acknowledge that it has been received
|
|
169
169
|
*/
|
|
170
|
-
HeartbeatAck = 11
|
|
170
|
+
HeartbeatAck = 11,
|
|
171
|
+
/**
|
|
172
|
+
* Used to request soundboard sounds for a list of guilds. The server will send Soundboard Sounds events for each guild in response.
|
|
173
|
+
*/
|
|
174
|
+
RequestSoundboardSounds = 31
|
|
171
175
|
}
|
|
172
176
|
/**
|
|
173
177
|
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
|
|
@@ -262,7 +266,7 @@ export declare enum GatewayIntentBits {
|
|
|
262
266
|
* @deprecated This is the old name for {@apilink GatewayIntentBits#GuildModeration}
|
|
263
267
|
*/
|
|
264
268
|
GuildBans = 4,
|
|
265
|
-
|
|
269
|
+
GuildExpressions = 8,
|
|
266
270
|
GuildIntegrations = 16,
|
|
267
271
|
GuildWebhooks = 32,
|
|
268
272
|
GuildInvites = 64,
|
|
@@ -347,6 +351,11 @@ export declare enum GatewayDispatchEvents {
|
|
|
347
351
|
GuildScheduledEventDelete = "GUILD_SCHEDULED_EVENT_DELETE",
|
|
348
352
|
GuildScheduledEventUserAdd = "GUILD_SCHEDULED_EVENT_USER_ADD",
|
|
349
353
|
GuildScheduledEventUserRemove = "GUILD_SCHEDULED_EVENT_USER_REMOVE",
|
|
354
|
+
GuildSoundboardSoundCreate = "GUILD_SOUNDBOARD_SOUND_CREATE",
|
|
355
|
+
GuildSoundboardSoundUpdate = "GUILD_SOUNDBOARD_SOUND_UPDATE",
|
|
356
|
+
GuildSoundboardSoundDelete = "GUILD_SOUNDBOARD_SOUND_DELETE",
|
|
357
|
+
GuildSoundboardSoundsUpdate = "GUILD_SOUNDBOARD_SOUNDS_UPDATE",
|
|
358
|
+
SoundboardSounds = "SOUNDBOARD_SOUNDS",
|
|
350
359
|
AutoModerationRuleCreate = "AUTO_MODERATION_RULE_CREATE",
|
|
351
360
|
AutoModerationRuleUpdate = "AUTO_MODERATION_RULE_UPDATE",
|
|
352
361
|
AutoModerationRuleDelete = "AUTO_MODERATION_RULE_DELETE",
|
package/lib/types/utils/index.js
CHANGED
|
@@ -153,6 +153,10 @@ var GatewayOpcodes;
|
|
|
153
153
|
* Sent in response to receiving a heartbeat to acknowledge that it has been received
|
|
154
154
|
*/
|
|
155
155
|
GatewayOpcodes[GatewayOpcodes["HeartbeatAck"] = 11] = "HeartbeatAck";
|
|
156
|
+
/**
|
|
157
|
+
* Used to request soundboard sounds for a list of guilds. The server will send Soundboard Sounds events for each guild in response.
|
|
158
|
+
*/
|
|
159
|
+
GatewayOpcodes[GatewayOpcodes["RequestSoundboardSounds"] = 31] = "RequestSoundboardSounds";
|
|
156
160
|
})(GatewayOpcodes || (exports.GatewayOpcodes = GatewayOpcodes = {}));
|
|
157
161
|
/**
|
|
158
162
|
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
|
|
@@ -248,9 +252,8 @@ var GatewayIntentBits;
|
|
|
248
252
|
/**
|
|
249
253
|
* @deprecated This is the old name for {@apilink GatewayIntentBits#GuildModeration}
|
|
250
254
|
*/
|
|
251
|
-
// biome-ignore lint/correctness/noUndeclaredVariables: no reason lmao
|
|
252
255
|
GatewayIntentBits[GatewayIntentBits["GuildBans"] = 4] = "GuildBans";
|
|
253
|
-
GatewayIntentBits[GatewayIntentBits["
|
|
256
|
+
GatewayIntentBits[GatewayIntentBits["GuildExpressions"] = 8] = "GuildExpressions";
|
|
254
257
|
GatewayIntentBits[GatewayIntentBits["GuildIntegrations"] = 16] = "GuildIntegrations";
|
|
255
258
|
GatewayIntentBits[GatewayIntentBits["GuildWebhooks"] = 32] = "GuildWebhooks";
|
|
256
259
|
GatewayIntentBits[GatewayIntentBits["GuildInvites"] = 64] = "GuildInvites";
|
|
@@ -336,6 +339,11 @@ var GatewayDispatchEvents;
|
|
|
336
339
|
GatewayDispatchEvents["GuildScheduledEventDelete"] = "GUILD_SCHEDULED_EVENT_DELETE";
|
|
337
340
|
GatewayDispatchEvents["GuildScheduledEventUserAdd"] = "GUILD_SCHEDULED_EVENT_USER_ADD";
|
|
338
341
|
GatewayDispatchEvents["GuildScheduledEventUserRemove"] = "GUILD_SCHEDULED_EVENT_USER_REMOVE";
|
|
342
|
+
GatewayDispatchEvents["GuildSoundboardSoundCreate"] = "GUILD_SOUNDBOARD_SOUND_CREATE";
|
|
343
|
+
GatewayDispatchEvents["GuildSoundboardSoundUpdate"] = "GUILD_SOUNDBOARD_SOUND_UPDATE";
|
|
344
|
+
GatewayDispatchEvents["GuildSoundboardSoundDelete"] = "GUILD_SOUNDBOARD_SOUND_DELETE";
|
|
345
|
+
GatewayDispatchEvents["GuildSoundboardSoundsUpdate"] = "GUILD_SOUNDBOARD_SOUNDS_UPDATE";
|
|
346
|
+
GatewayDispatchEvents["SoundboardSounds"] = "SOUNDBOARD_SOUNDS";
|
|
339
347
|
GatewayDispatchEvents["AutoModerationRuleCreate"] = "AUTO_MODERATION_RULE_CREATE";
|
|
340
348
|
GatewayDispatchEvents["AutoModerationRuleUpdate"] = "AUTO_MODERATION_RULE_UPDATE";
|
|
341
349
|
GatewayDispatchEvents["AutoModerationRuleDelete"] = "AUTO_MODERATION_RULE_DELETE";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RestToKeys } from '../common';
|
|
2
|
-
import type {
|
|
2
|
+
import type { APIAuditLogEntry, APIAutoModerationRule, APIChannel, APIEntitlement, APIGuild, APIGuildMember, APIGuildScheduledEvent, APIStageInstance, APISubscription, APIUser, GatewayActivity, GatewayAutoModerationActionExecutionDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayChannelUpdateDispatchData, GatewayEntitlementCreateDispatchData, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, GatewayGuildCreateDispatchData, GatewayGuildDeleteDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberAddDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberUpdateDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, GatewayGuildSoundboardSoundDeleteDispatchData, GatewayGuildSoundboardSoundsUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayIntegrationCreateDispatchData, GatewayIntegrationDeleteDispatchData, GatewayInteractionCreateDispatchData, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageCreateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageDeleteDispatchData, GatewayMessagePollVoteDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayMessageUpdateDispatchData, GatewayPresenceUpdateData, GatewayPresenceUpdateDispatchData, GatewayReadyDispatchData, GatewayRequestGuildMembersDataWithQuery, GatewayRequestGuildMembersDataWithUserIds, GatewaySoundboardSoundsDispatchData, GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayVoiceChannelEffectSendDispachData, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateData, GatewayWebhooksUpdateDispatchData, PresenceUpdateStatus } from '../types';
|
|
3
3
|
import { GatewayDispatchEvents } from '../types';
|
|
4
|
+
import type { APISoundBoard } from '../types/payloads/soundboard';
|
|
4
5
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
|
5
6
|
export interface StatusUpdate {
|
|
6
7
|
/** The user's activities */
|
|
@@ -55,6 +56,9 @@ export interface Events {
|
|
|
55
56
|
[GatewayDispatchEvents.GuildEmojisUpdate]: GatewayGuildEmojisUpdateDispatchData;
|
|
56
57
|
[GatewayDispatchEvents.GuildStickersUpdate]: GatewayGuildStickersUpdateDispatchData;
|
|
57
58
|
[GatewayDispatchEvents.GuildIntegrationsUpdate]: GatewayGuildIntegrationsUpdateDispatchData;
|
|
59
|
+
[GatewayDispatchEvents.GuildSoundboardSoundsUpdate]: GatewayGuildSoundboardSoundsUpdateDispatchData;
|
|
60
|
+
[GatewayDispatchEvents.GuildSoundboardSoundDelete]: GatewayGuildSoundboardSoundDeleteDispatchData;
|
|
61
|
+
[GatewayDispatchEvents.SoundboardSounds]: GatewaySoundboardSoundsDispatchData;
|
|
58
62
|
[GatewayDispatchEvents.GuildMemberAdd]: GatewayGuildMemberAddDispatchData;
|
|
59
63
|
[GatewayDispatchEvents.GuildMemberRemove]: GatewayGuildMemberRemoveDispatchData;
|
|
60
64
|
[GatewayDispatchEvents.GuildMemberUpdate]: GatewayGuildMemberUpdateDispatchData;
|
|
@@ -133,7 +137,12 @@ export type SubscriptionEvents = RestToKeys<[
|
|
|
133
137
|
GatewayDispatchEvents.SubscriptionDelete,
|
|
134
138
|
GatewayDispatchEvents.SubscriptionUpdate
|
|
135
139
|
]>;
|
|
136
|
-
export type
|
|
140
|
+
export type SoundboardSoundsEvents = RestToKeys<[
|
|
141
|
+
APISoundBoard,
|
|
142
|
+
GatewayDispatchEvents.GuildSoundboardSoundCreate,
|
|
143
|
+
GatewayDispatchEvents.GuildSoundboardSoundUpdate
|
|
144
|
+
]>;
|
|
145
|
+
export type NormalizeEvents = Events & AutoModetaractionRuleEvents & ChannelSameEvents & GuildScheduledSameEvents & GuildScheduledUserSameEvents & IntegrationSameEvents & EntitlementEvents & PollVoteSameEvents & StageSameEvents & SubscriptionEvents & SoundboardSoundsEvents & {
|
|
137
146
|
RAW: GatewayDispatchEvents;
|
|
138
147
|
};
|
|
139
148
|
export type GatewayEvents = {
|
|
@@ -17,24 +17,14 @@ const ShardManagerDefaults = {
|
|
|
17
17
|
properties,
|
|
18
18
|
version: 10,
|
|
19
19
|
shardStart: 0,
|
|
20
|
-
handlePayload: (shardId, packet) => {
|
|
21
|
-
console.info(`Packet ${packet.t} on shard ${shardId}`);
|
|
22
|
-
},
|
|
23
20
|
resharding: {
|
|
24
21
|
interval: 8 * 60 * 60 * 1e3, // 8h
|
|
25
22
|
percentage: 80,
|
|
26
|
-
reloadGuilds() {
|
|
27
|
-
throw new Error('Unexpected to run <reloadGuilds>');
|
|
28
|
-
},
|
|
29
|
-
onGuild() {
|
|
30
|
-
throw new Error('Unexpected to run <onGuild>');
|
|
31
|
-
},
|
|
32
23
|
},
|
|
33
24
|
};
|
|
34
25
|
exports.ShardManagerDefaults = ShardManagerDefaults;
|
|
35
26
|
const WorkerManagerDefaults = {
|
|
36
27
|
...ShardManagerDefaults,
|
|
37
28
|
shardsPerWorker: 16,
|
|
38
|
-
handlePayload: (_shardId, _workerId, _packet) => { },
|
|
39
29
|
};
|
|
40
30
|
exports.WorkerManagerDefaults = WorkerManagerDefaults;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SeyfertWebSocket } from './socket/custom';
|
|
2
2
|
export declare class BaseSocket {
|
|
3
3
|
private internal;
|
|
4
|
-
ping
|
|
4
|
+
ping: () => Promise<number>;
|
|
5
5
|
constructor(kind: 'ws' | 'bun', url: string);
|
|
6
6
|
set onopen(callback: SeyfertWebSocket['onopen']);
|
|
7
7
|
set onmessage(callback: SeyfertWebSocket['onmessage']);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Logger, type MakeRequired } from '../../common';
|
|
2
|
+
import { type GatewayReceivePayload, type GatewaySendPayload } from '../../types';
|
|
2
3
|
import { DynamicBucket } from '../structures';
|
|
3
4
|
import { ConnectTimeout } from '../structures/timeout';
|
|
4
5
|
import { BaseSocket } from './basesocket';
|
|
5
6
|
import type { ShardData, ShardOptions } from './shared';
|
|
6
|
-
import { type GatewaySendPayload, type GatewayReceivePayload } from '../../types';
|
|
7
7
|
export interface ShardHeart {
|
|
8
8
|
interval: number;
|
|
9
9
|
nodeInterval?: NodeJS.Timeout;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Shard = void 0;
|
|
4
4
|
const node_zlib_1 = require("node:zlib");
|
|
5
5
|
const common_1 = require("../../common");
|
|
6
|
+
const types_1 = require("../../types");
|
|
6
7
|
const constants_1 = require("../constants");
|
|
7
8
|
const structures_1 = require("../structures");
|
|
8
9
|
const timeout_1 = require("../structures/timeout");
|
|
9
10
|
const basesocket_1 = require("./basesocket");
|
|
10
11
|
const shared_1 = require("./shared");
|
|
11
|
-
const types_1 = require("../../types");
|
|
12
12
|
class Shard {
|
|
13
13
|
id;
|
|
14
14
|
logger;
|
|
@@ -65,7 +65,6 @@ class Shard {
|
|
|
65
65
|
ping() {
|
|
66
66
|
if (!this.websocket)
|
|
67
67
|
return Promise.resolve(Number.POSITIVE_INFINITY);
|
|
68
|
-
//@ts-expect-error
|
|
69
68
|
return this.websocket.ping();
|
|
70
69
|
}
|
|
71
70
|
async connect() {
|
|
@@ -171,8 +170,10 @@ class Shard {
|
|
|
171
170
|
}
|
|
172
171
|
break;
|
|
173
172
|
case types_1.GatewayOpcodes.HeartbeatAck:
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
{
|
|
174
|
+
this.heart.ack = true;
|
|
175
|
+
this.heart.lastAck = Date.now();
|
|
176
|
+
}
|
|
176
177
|
break;
|
|
177
178
|
case types_1.GatewayOpcodes.Heartbeat:
|
|
178
179
|
this.heartbeat(true);
|
|
@@ -197,8 +198,10 @@ class Shard {
|
|
|
197
198
|
{
|
|
198
199
|
switch (packet.t) {
|
|
199
200
|
case types_1.GatewayDispatchEvents.Resumed:
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
{
|
|
202
|
+
this.offlineSendQueue.map((resolve) => resolve());
|
|
203
|
+
this.options.handlePayload(this.id, packet);
|
|
204
|
+
}
|
|
202
205
|
break;
|
|
203
206
|
case types_1.GatewayDispatchEvents.Ready: {
|
|
204
207
|
this.data.resume_gateway_url = packet.d.resume_gateway_url;
|
|
@@ -226,10 +229,12 @@ class Shard {
|
|
|
226
229
|
case types_1.GatewayCloseCodes.UnknownOpcode:
|
|
227
230
|
case types_1.GatewayCloseCodes.InvalidSeq:
|
|
228
231
|
case types_1.GatewayCloseCodes.SessionTimedOut:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
232
|
+
{
|
|
233
|
+
this.data.resume_seq = 0;
|
|
234
|
+
this.data.session_id = undefined;
|
|
235
|
+
this.data.resume_gateway_url = undefined;
|
|
236
|
+
await this.reconnect();
|
|
237
|
+
}
|
|
233
238
|
break;
|
|
234
239
|
case 1001:
|
|
235
240
|
case 1006:
|
|
@@ -239,8 +244,10 @@ class Shard {
|
|
|
239
244
|
case types_1.GatewayCloseCodes.NotAuthenticated:
|
|
240
245
|
case types_1.GatewayCloseCodes.AlreadyAuthenticated:
|
|
241
246
|
case types_1.GatewayCloseCodes.RateLimited:
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
{
|
|
248
|
+
this.logger.info('Trying to reconnect');
|
|
249
|
+
await this.reconnect();
|
|
250
|
+
}
|
|
244
251
|
break;
|
|
245
252
|
case types_1.GatewayCloseCodes.AuthenticationFailed:
|
|
246
253
|
case types_1.GatewayCloseCodes.DisallowedIntents:
|
|
@@ -251,17 +258,19 @@ class Shard {
|
|
|
251
258
|
this.logger.fatal('Cannot reconnect');
|
|
252
259
|
break;
|
|
253
260
|
default:
|
|
254
|
-
|
|
255
|
-
|
|
261
|
+
{
|
|
262
|
+
this.logger.warn('Unknown close code, trying to reconnect anyways');
|
|
263
|
+
await this.reconnect();
|
|
264
|
+
}
|
|
256
265
|
break;
|
|
257
266
|
}
|
|
258
267
|
}
|
|
259
268
|
async close(code, reason) {
|
|
260
269
|
clearInterval(this.heart.nodeInterval);
|
|
261
270
|
if (!this.isOpen) {
|
|
262
|
-
return this.debugger?.warn(`[Shard #${this.id}] Is not open
|
|
271
|
+
return this.debugger?.warn(`[Shard #${this.id}] Is not open, reason:`, reason);
|
|
263
272
|
}
|
|
264
|
-
this.debugger?.debug(`[Shard #${this.id}] Called close
|
|
273
|
+
this.debugger?.debug(`[Shard #${this.id}] Called close with reason:`, reason);
|
|
265
274
|
this.websocket?.close(code, reason);
|
|
266
275
|
}
|
|
267
276
|
handleMessage(data) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Logger, type MakeRequired } from '../../common';
|
|
2
|
-
import
|
|
2
|
+
import type { MakeDeepPartial } from '../../common/types/util';
|
|
3
|
+
import { type GatewaySendPayload, type GatewayUpdatePresence, type GatewayVoiceStateUpdate } from '../../types';
|
|
3
4
|
import { ShardManagerDefaults } from '../constants';
|
|
4
5
|
import { ConnectQueue } from '../structures/timeout';
|
|
5
6
|
import { Shard } from './shard';
|
|
6
|
-
import type { ShardManagerOptions } from './shared';
|
|
7
|
+
import type { ShardData, ShardManagerOptions } from './shared';
|
|
7
8
|
export declare class ShardManager extends Map<number, Shard> {
|
|
8
9
|
connectQueue: ConnectQueue;
|
|
9
10
|
options: MakeRequired<ShardManagerOptions, keyof typeof ShardManagerDefaults>;
|
|
10
11
|
debugger?: Logger;
|
|
11
|
-
constructor(options: ShardManagerOptions);
|
|
12
|
+
constructor(options: MakeDeepPartial<ShardManagerOptions, 'resharding'>);
|
|
12
13
|
get totalShards(): number;
|
|
13
14
|
get shardStart(): number;
|
|
14
15
|
get shardEnd(): number;
|
|
@@ -16,15 +17,17 @@ export declare class ShardManager extends Map<number, Shard> {
|
|
|
16
17
|
get concurrency(): number;
|
|
17
18
|
get latency(): number;
|
|
18
19
|
calculateShardId(guildId: string): number;
|
|
19
|
-
|
|
20
|
+
create(shardId: number): Shard;
|
|
20
21
|
spawnShards(): Promise<void>;
|
|
22
|
+
startResharder(): Promise<void>;
|
|
21
23
|
spawnBuckets(): Shard[][];
|
|
22
24
|
forceIdentify(shardId: number): Promise<void>;
|
|
23
25
|
disconnect(shardId: number): Promise<void> | undefined;
|
|
24
|
-
disconnectAll():
|
|
26
|
+
disconnectAll(): void;
|
|
25
27
|
setShardPresence(shardId: number, payload: GatewayUpdatePresence['d']): void;
|
|
26
|
-
setPresence(payload: GatewayUpdatePresence['d']):
|
|
28
|
+
setPresence(payload: GatewayUpdatePresence['d']): void;
|
|
27
29
|
joinVoice(guild_id: string, channel_id: string, options: Pick<GatewayVoiceStateUpdate['d'], 'self_deaf' | 'self_mute'>): void;
|
|
28
30
|
leaveVoice(guild_id: string): void;
|
|
29
31
|
send<T extends GatewaySendPayload>(shardId: number, payload: T): void;
|
|
32
|
+
resume(shardId: number, shardData: MakeRequired<ShardData>): unknown;
|
|
30
33
|
}
|
|
@@ -31,64 +31,6 @@ class ShardManager extends Map {
|
|
|
31
31
|
if (worker_threads.parentPort)
|
|
32
32
|
parentPort = worker_threads.parentPort;
|
|
33
33
|
}
|
|
34
|
-
if (this.options.resharding.interval <= 0)
|
|
35
|
-
return;
|
|
36
|
-
setInterval(async () => {
|
|
37
|
-
this.debugger?.debug('Checking if reshard is needed');
|
|
38
|
-
const info = await this.options.resharding.getInfo();
|
|
39
|
-
if (info.shards <= this.totalShards)
|
|
40
|
-
return this.debugger?.debug('Resharding not needed');
|
|
41
|
-
//https://github.com/discordeno/discordeno/blob/6a5f446c0651b9fad9f1550ff1857fe7a026426b/packages/gateway/src/manager.ts#L106C8-L106C94
|
|
42
|
-
const percentage = (info.shards / ((this.totalShards * 2500) / 1000)) * 100;
|
|
43
|
-
if (percentage < this.options.resharding.percentage)
|
|
44
|
-
return this.debugger?.debug(`Percentage is not enough to reshard ${percentage}/${this.options.resharding.percentage}`);
|
|
45
|
-
this.debugger?.info('Starting resharding process');
|
|
46
|
-
this.connectQueue.concurrency = info.session_start_limit.max_concurrency;
|
|
47
|
-
this.options.totalShards = info.shards;
|
|
48
|
-
this.options.info.session_start_limit.max_concurrency = info.session_start_limit.max_concurrency;
|
|
49
|
-
let shardsConnected = 0;
|
|
50
|
-
let handlePayload = async (sharder, _, packet) => {
|
|
51
|
-
if ((packet.t === 'GUILD_CREATE' || packet.t === 'GUILD_DELETE') &&
|
|
52
|
-
this.options.resharding.onGuild(packet.d.id)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (packet.t !== 'READY')
|
|
56
|
-
return;
|
|
57
|
-
this.options.resharding.reloadGuilds(packet.d.guilds.map(x => x.id));
|
|
58
|
-
if (++shardsConnected < info.shards)
|
|
59
|
-
return; //waiting for last shard to connect
|
|
60
|
-
// dont listen more events when all shards are ready
|
|
61
|
-
handlePayload = async () => { };
|
|
62
|
-
await this.disconnectAll();
|
|
63
|
-
this.clear();
|
|
64
|
-
for (const [id, shard] of sharder) {
|
|
65
|
-
shard.options.handlePayload = (shardId, packet) => {
|
|
66
|
-
return this.options.handlePayload(shardId, packet);
|
|
67
|
-
};
|
|
68
|
-
this.set(id, shard);
|
|
69
|
-
}
|
|
70
|
-
sharder.clear();
|
|
71
|
-
};
|
|
72
|
-
const resharder = new ShardManager({
|
|
73
|
-
...this.options,
|
|
74
|
-
resharding: {
|
|
75
|
-
// getInfo mock, we don't need it
|
|
76
|
-
getInfo: () => ({}),
|
|
77
|
-
interval: 0,
|
|
78
|
-
percentage: 0,
|
|
79
|
-
reloadGuilds() { },
|
|
80
|
-
onGuild() {
|
|
81
|
-
return true;
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
handlePayload: (shardId, packet) => {
|
|
85
|
-
return handlePayload(resharder, shardId, packet);
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
// share ratelimit
|
|
89
|
-
resharder.connectQueue = this.connectQueue;
|
|
90
|
-
await resharder.spawnShards();
|
|
91
|
-
}, this.options.resharding.interval);
|
|
92
34
|
}
|
|
93
35
|
get totalShards() {
|
|
94
36
|
return this.options.totalShards ?? this.options.info.shards;
|
|
@@ -113,8 +55,8 @@ class ShardManager extends Map {
|
|
|
113
55
|
calculateShardId(guildId) {
|
|
114
56
|
return (0, common_1.calculateShardId)(guildId, this.totalShards);
|
|
115
57
|
}
|
|
116
|
-
|
|
117
|
-
this.debugger?.info(`
|
|
58
|
+
create(shardId) {
|
|
59
|
+
this.debugger?.info(`Creating shard ${shardId}`);
|
|
118
60
|
let shard = this.get(shardId);
|
|
119
61
|
shard ??= new shard_1.Shard(shardId, {
|
|
120
62
|
token: this.options.token,
|
|
@@ -131,7 +73,7 @@ class ShardManager extends Map {
|
|
|
131
73
|
}
|
|
132
74
|
async spawnShards() {
|
|
133
75
|
const buckets = this.spawnBuckets();
|
|
134
|
-
this.debugger?.info('
|
|
76
|
+
this.debugger?.info('Spawning shards');
|
|
135
77
|
for (const bucket of buckets) {
|
|
136
78
|
for (const shard of bucket) {
|
|
137
79
|
if (!shard) {
|
|
@@ -141,6 +83,81 @@ class ShardManager extends Map {
|
|
|
141
83
|
this.connectQueue.push(shard.connect.bind(shard));
|
|
142
84
|
}
|
|
143
85
|
}
|
|
86
|
+
await this.startResharder();
|
|
87
|
+
}
|
|
88
|
+
async startResharder() {
|
|
89
|
+
if (this.options.resharding.interval <= 0)
|
|
90
|
+
return;
|
|
91
|
+
if (this.shardStart !== 0 || this.shardEnd !== this.totalShards)
|
|
92
|
+
return this.debugger?.debug('Cannot start resharder');
|
|
93
|
+
this.debugger?.debug('Resharder enabled');
|
|
94
|
+
setInterval(async () => {
|
|
95
|
+
this.debugger?.debug('Checking if reshard is needed');
|
|
96
|
+
const info = await this.options.resharding.getInfo();
|
|
97
|
+
if (info.shards <= this.totalShards)
|
|
98
|
+
return this.debugger?.debug('Resharding not needed');
|
|
99
|
+
//https://github.com/discordeno/discordeno/blob/6a5f446c0651b9fad9f1550ff1857fe7a026426b/packages/gateway/src/manager.ts#L106C8-L106C94
|
|
100
|
+
const percentage = (info.shards / ((this.totalShards * 2500) / 1000)) * 100;
|
|
101
|
+
if (percentage < this.options.resharding.percentage)
|
|
102
|
+
return this.debugger?.debug(`Percentage is not enough to reshard ${percentage}/${this.options.resharding.percentage}`);
|
|
103
|
+
this.debugger?.info('Starting resharding process');
|
|
104
|
+
this.connectQueue.concurrency = info.session_start_limit.max_concurrency;
|
|
105
|
+
this.options.info.session_start_limit.max_concurrency = info.session_start_limit.max_concurrency;
|
|
106
|
+
//waiting for all shards to connect
|
|
107
|
+
let shardsConnected = 0;
|
|
108
|
+
const handleGuilds = new Set();
|
|
109
|
+
let handlePayload = async (sharder, _, packet) => {
|
|
110
|
+
if (packet.t === 'GUILD_CREATE' || packet.t === 'GUILD_DELETE') {
|
|
111
|
+
handleGuilds.delete(packet.d.id);
|
|
112
|
+
if (shardsConnected === info.shards && !handleGuilds.size) {
|
|
113
|
+
return cleanProcess(sharder);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (packet.t !== 'READY')
|
|
117
|
+
return;
|
|
118
|
+
for (const guild of packet.d.guilds) {
|
|
119
|
+
handleGuilds.add(guild.id);
|
|
120
|
+
}
|
|
121
|
+
if (++shardsConnected < info.shards || handleGuilds.size)
|
|
122
|
+
return;
|
|
123
|
+
cleanProcess(sharder);
|
|
124
|
+
// dont listen more events when all shards are ready
|
|
125
|
+
};
|
|
126
|
+
const cleanProcess = (sharder) => {
|
|
127
|
+
handlePayload = async () => {
|
|
128
|
+
//
|
|
129
|
+
};
|
|
130
|
+
this.disconnectAll();
|
|
131
|
+
this.clear();
|
|
132
|
+
this.options.totalShards = this.options.shardEnd = info.shards;
|
|
133
|
+
for (const [id, shard] of sharder) {
|
|
134
|
+
shard.options.handlePayload = (shardId, packet) => {
|
|
135
|
+
return this.options.handlePayload(shardId, packet);
|
|
136
|
+
};
|
|
137
|
+
this.set(id, shard);
|
|
138
|
+
}
|
|
139
|
+
sharder.clear();
|
|
140
|
+
};
|
|
141
|
+
const options = (0, common_1.MergeOptions)(this.options, {
|
|
142
|
+
totalShards: info.shards,
|
|
143
|
+
shardEnd: info.shards,
|
|
144
|
+
});
|
|
145
|
+
const resharder = new ShardManager({
|
|
146
|
+
...options,
|
|
147
|
+
resharding: {
|
|
148
|
+
// getInfo mock, we don't need it
|
|
149
|
+
getInfo: () => ({}),
|
|
150
|
+
interval: 0,
|
|
151
|
+
percentage: 0,
|
|
152
|
+
},
|
|
153
|
+
handlePayload: (shardId, packet) => {
|
|
154
|
+
return handlePayload(resharder, shardId, packet);
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
// share ratelimit
|
|
158
|
+
resharder.connectQueue = this.connectQueue;
|
|
159
|
+
await resharder.spawnShards();
|
|
160
|
+
}, this.options.resharding.interval);
|
|
144
161
|
}
|
|
145
162
|
/*
|
|
146
163
|
* spawns buckets in order
|
|
@@ -152,7 +169,7 @@ class ShardManager extends Map {
|
|
|
152
169
|
chunks.forEach((arr, index) => {
|
|
153
170
|
for (let i = 0; i < arr.length; i++) {
|
|
154
171
|
const id = i + (index > 0 ? index * this.concurrency : 0) + this.shardStart;
|
|
155
|
-
chunks[index][i] = this.
|
|
172
|
+
chunks[index][i] = this.create(id);
|
|
156
173
|
}
|
|
157
174
|
});
|
|
158
175
|
this.debugger?.info(`${chunks.length} buckets created`);
|
|
@@ -160,7 +177,7 @@ class ShardManager extends Map {
|
|
|
160
177
|
}
|
|
161
178
|
forceIdentify(shardId) {
|
|
162
179
|
this.debugger?.info(`Shard #${shardId} force identify`);
|
|
163
|
-
return this.
|
|
180
|
+
return this.create(shardId).identify();
|
|
164
181
|
}
|
|
165
182
|
disconnect(shardId) {
|
|
166
183
|
this.debugger?.info(`Shard #${shardId} force disconnect`);
|
|
@@ -168,10 +185,7 @@ class ShardManager extends Map {
|
|
|
168
185
|
}
|
|
169
186
|
disconnectAll() {
|
|
170
187
|
this.debugger?.info('Disconnect all shards');
|
|
171
|
-
|
|
172
|
-
this.forEach(shard => shard.disconnect());
|
|
173
|
-
resolve(null);
|
|
174
|
-
});
|
|
188
|
+
this.forEach(shard => shard.disconnect());
|
|
175
189
|
}
|
|
176
190
|
setShardPresence(shardId, payload) {
|
|
177
191
|
this.debugger?.info(`Shard #${shardId} update presence`);
|
|
@@ -181,12 +195,9 @@ class ShardManager extends Map {
|
|
|
181
195
|
});
|
|
182
196
|
}
|
|
183
197
|
setPresence(payload) {
|
|
184
|
-
|
|
185
|
-
this.
|
|
186
|
-
|
|
187
|
-
}, this);
|
|
188
|
-
resolve();
|
|
189
|
-
});
|
|
198
|
+
this.forEach(shard => {
|
|
199
|
+
this.setShardPresence(shard.id, payload);
|
|
200
|
+
}, this);
|
|
190
201
|
}
|
|
191
202
|
joinVoice(guild_id, channel_id, options) {
|
|
192
203
|
const shardId = this.calculateShardId(guild_id);
|
|
@@ -202,7 +213,6 @@ class ShardManager extends Map {
|
|
|
202
213
|
}
|
|
203
214
|
leaveVoice(guild_id) {
|
|
204
215
|
const shardId = this.calculateShardId(guild_id);
|
|
205
|
-
this.debugger?.info(`Shard #${shardId} leave voice in ${guild_id}`);
|
|
206
216
|
return this.send(shardId, {
|
|
207
217
|
op: types_1.GatewayOpcodes.VoiceStateUpdate,
|
|
208
218
|
d: {
|
|
@@ -223,5 +233,12 @@ class ShardManager extends Map {
|
|
|
223
233
|
}
|
|
224
234
|
this.get(shardId)?.send(false, payload);
|
|
225
235
|
}
|
|
236
|
+
resume(shardId, shardData) {
|
|
237
|
+
if (this.has(shardId))
|
|
238
|
+
throw new Error('Cannot override existing shard');
|
|
239
|
+
const shard = this.create(shardId);
|
|
240
|
+
shard.data = shardData;
|
|
241
|
+
return this.connectQueue.push(shard.connect.bind(shard));
|
|
242
|
+
}
|
|
226
243
|
}
|
|
227
244
|
exports.ShardManager = ShardManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { APIGatewayBotInfo, GatewayDispatchPayload, GatewayIntentBits, GatewayPresenceUpdateData } from '../../types';
|
|
2
1
|
import type { Awaitable, DeepPartial, Logger } from '../../common';
|
|
2
|
+
import type { APIGatewayBotInfo, GatewayDispatchPayload, GatewayIntentBits, GatewayPresenceUpdateData } from '../../types';
|
|
3
3
|
import type { IdentifyProperties } from '../constants';
|
|
4
4
|
export interface ShardManagerOptions extends ShardDetails {
|
|
5
5
|
/** Important data which is used by the manager to connect shards to the gateway. */
|
|
@@ -36,18 +36,6 @@ export interface ShardManagerOptions extends ShardDetails {
|
|
|
36
36
|
getInfo(): Promise<APIGatewayBotInfo>;
|
|
37
37
|
interval: number;
|
|
38
38
|
percentage: number;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param ids
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
reloadGuilds: (ids: string[]) => unknown;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param id
|
|
48
|
-
* @returns true if deleted
|
|
49
|
-
*/
|
|
50
|
-
onGuild: (id: string) => boolean;
|
|
51
39
|
};
|
|
52
40
|
}
|
|
53
41
|
export interface CustomManagerAdapter {
|
|
@@ -64,7 +52,7 @@ export interface WorkerManagerOptions extends Omit<ShardManagerOptions, 'handleP
|
|
|
64
52
|
shardsPerWorker?: number;
|
|
65
53
|
workerProxy?: boolean;
|
|
66
54
|
path: string;
|
|
67
|
-
handlePayload(shardId: number, workerId: number, packet: GatewayDispatchPayload):
|
|
55
|
+
handlePayload?(shardId: number, workerId: number, packet: GatewayDispatchPayload): any;
|
|
68
56
|
properties?: DeepPartial<NonNullable<ShardManagerOptions['properties']>>;
|
|
69
57
|
}
|
|
70
58
|
export interface ShardData {
|
|
@@ -129,4 +117,5 @@ export interface WorkerData {
|
|
|
129
117
|
debug: boolean;
|
|
130
118
|
workerProxy: boolean;
|
|
131
119
|
__USING_WATCHER__?: boolean;
|
|
120
|
+
resharding: boolean;
|
|
132
121
|
}
|
|
@@ -186,12 +186,24 @@ class SeyfertWebSocket {
|
|
|
186
186
|
frame.set(buffer, frame.length - length);
|
|
187
187
|
this.socket?.write(frame);
|
|
188
188
|
}
|
|
189
|
-
onping(_data) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
onping(_data) {
|
|
190
|
+
//
|
|
191
|
+
}
|
|
192
|
+
onpong(_data) {
|
|
193
|
+
//
|
|
194
|
+
}
|
|
195
|
+
onopen() {
|
|
196
|
+
//
|
|
197
|
+
}
|
|
198
|
+
onmessage(_payload) {
|
|
199
|
+
//
|
|
200
|
+
}
|
|
201
|
+
onclose(_close) {
|
|
202
|
+
//
|
|
203
|
+
}
|
|
204
|
+
onerror(_err) {
|
|
205
|
+
//
|
|
206
|
+
}
|
|
195
207
|
close(code, reason) {
|
|
196
208
|
this.__closeCalled = true;
|
|
197
209
|
// alloc payload length
|
|
@@ -203,6 +215,7 @@ class SeyfertWebSocket {
|
|
|
203
215
|
// message, close opcode
|
|
204
216
|
this._write(buffer, 0x8);
|
|
205
217
|
this.socket?.end();
|
|
218
|
+
this.onclose({ code, reason });
|
|
206
219
|
}
|
|
207
220
|
pong(data) {
|
|
208
221
|
//send pong opcode (10)
|
|
@@ -9,13 +9,16 @@ export interface WorkerShardInfo {
|
|
|
9
9
|
export type WorkerInfo = {
|
|
10
10
|
shards: WorkerShardInfo[];
|
|
11
11
|
};
|
|
12
|
-
type CreateWorkerMessage<T extends string, D extends object =
|
|
12
|
+
type CreateWorkerMessage<T extends string, D extends object = object> = {
|
|
13
13
|
type: T;
|
|
14
14
|
workerId: number;
|
|
15
15
|
} & D;
|
|
16
16
|
export type WorkerRequestConnect = CreateWorkerMessage<'CONNECT_QUEUE', {
|
|
17
17
|
shardId: number;
|
|
18
18
|
}>;
|
|
19
|
+
export type WorkerRequestConnectResharding = CreateWorkerMessage<'CONNECT_QUEUE_RESHARDING', {
|
|
20
|
+
shardId: number;
|
|
21
|
+
}>;
|
|
19
22
|
export type WorkerReceivePayload = CreateWorkerMessage<'RECEIVE_PAYLOAD', {
|
|
20
23
|
shardId: number;
|
|
21
24
|
payload: GatewayDispatchPayload;
|
|
@@ -35,8 +38,11 @@ export type WorkerSendInfo = CreateWorkerMessage<'WORKER_INFO', WorkerInfo & {
|
|
|
35
38
|
nonce: string;
|
|
36
39
|
}>;
|
|
37
40
|
export type WorkerReady = CreateWorkerMessage<'WORKER_READY'>;
|
|
41
|
+
export type WorkerReadyResharding = CreateWorkerMessage<'WORKER_READY_RESHARDING'>;
|
|
38
42
|
export type WorkerShardsConnected = CreateWorkerMessage<'WORKER_SHARDS_CONNECTED'>;
|
|
39
43
|
export type WorkerStart = CreateWorkerMessage<'WORKER_START'>;
|
|
44
|
+
export type WorkerStartResharding = CreateWorkerMessage<'WORKER_START_RESHARDING'>;
|
|
45
|
+
export type WorkerDisconnectedAllShardsResharding = CreateWorkerMessage<'DISCONNECTED_ALL_SHARDS_RESHARDING'>;
|
|
40
46
|
export type WorkerSendApiRequest = CreateWorkerMessage<'WORKER_API_REQUEST', {
|
|
41
47
|
method: HttpMethods;
|
|
42
48
|
url: `/${string}`;
|
|
@@ -52,5 +58,5 @@ export type WorkerSendEval = CreateWorkerMessage<'EVAL', {
|
|
|
52
58
|
nonce: string;
|
|
53
59
|
toWorkerId: number;
|
|
54
60
|
}>;
|
|
55
|
-
export type WorkerMessage = WorkerRequestConnect | WorkerReceivePayload | WorkerSendResultPayload | WorkerSendCacheRequest | WorkerSendShardInfo | WorkerSendInfo | WorkerReady | WorkerShardsConnected | WorkerSendApiRequest | WorkerSendEvalResponse | WorkerSendEval | WorkerStart;
|
|
61
|
+
export type WorkerMessage = WorkerRequestConnect | WorkerReceivePayload | WorkerSendResultPayload | WorkerSendCacheRequest | WorkerSendShardInfo | WorkerSendInfo | WorkerReady | WorkerShardsConnected | WorkerSendApiRequest | WorkerSendEvalResponse | WorkerSendEval | WorkerStart | WorkerStartResharding | WorkerRequestConnectResharding | WorkerReadyResharding | WorkerDisconnectedAllShardsResharding;
|
|
56
62
|
export {};
|