seyfert 1.4.0 → 2.0.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/LICENSE +21 -190
- package/README.md +22 -14
- package/lib/api/Router.js +5 -3
- package/lib/api/Routes/applications.d.ts +23 -1
- package/lib/api/Routes/channels.d.ts +1 -1
- package/lib/api/Routes/gateway.d.ts +1 -1
- package/lib/api/Routes/guilds.d.ts +8 -2
- package/lib/api/Routes/interactions.d.ts +1 -1
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/stage-instances.d.ts +1 -1
- package/lib/api/Routes/stickers.d.ts +2 -2
- package/lib/api/Routes/users.d.ts +1 -1
- package/lib/api/Routes/voice.d.ts +1 -1
- package/lib/api/Routes/webhooks.d.ts +2 -2
- package/lib/api/api.d.ts +2 -2
- package/lib/api/api.js +2 -14
- package/lib/api/bucket.d.ts +0 -1
- package/lib/api/shared.d.ts +0 -1
- package/lib/api/utils/constants.d.ts +2 -5
- package/lib/api/utils/constants.js +3 -7
- package/lib/api/utils/utils.d.ts +1 -2
- package/lib/api/utils/utils.js +2 -3
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/ActionRow.js +3 -3
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/builders/Attachment.js +12 -13
- package/lib/builders/Base.d.ts +2 -2
- package/lib/builders/Base.js +1 -1
- package/lib/builders/Button.d.ts +7 -7
- package/lib/builders/Button.js +11 -9
- package/lib/builders/Embed.d.ts +1 -1
- package/lib/builders/Modal.d.ts +1 -1
- package/lib/builders/Modal.js +2 -2
- package/lib/builders/Poll.d.ts +2 -2
- package/lib/builders/Poll.js +5 -6
- package/lib/builders/SelectMenu.d.ts +1 -1
- package/lib/builders/SelectMenu.js +17 -18
- package/lib/builders/index.d.ts +1 -1
- package/lib/builders/index.js +10 -11
- package/lib/cache/adapters/default.d.ts +16 -9
- package/lib/cache/adapters/default.js +42 -31
- package/lib/cache/adapters/index.d.ts +0 -1
- package/lib/cache/adapters/index.js +0 -1
- package/lib/cache/adapters/limited.d.ts +17 -12
- package/lib/cache/adapters/limited.js +80 -36
- package/lib/cache/adapters/types.d.ts +6 -7
- package/lib/cache/adapters/workeradapter.d.ts +6 -6
- package/lib/cache/adapters/workeradapter.js +13 -0
- package/lib/cache/index.d.ts +24 -11
- package/lib/cache/index.js +335 -19
- package/lib/cache/resources/bans.d.ts +15 -0
- package/lib/cache/resources/bans.js +44 -0
- package/lib/cache/resources/channels.d.ts +6 -4
- package/lib/cache/resources/channels.js +13 -7
- package/lib/cache/resources/default/base.d.ts +7 -7
- package/lib/cache/resources/default/base.js +2 -2
- package/lib/cache/resources/default/guild-based.d.ts +6 -6
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +7 -7
- package/lib/cache/resources/default/guild-related.js +10 -8
- package/lib/cache/resources/emojis.d.ts +15 -6
- package/lib/cache/resources/emojis.js +13 -4
- package/lib/cache/resources/guilds.d.ts +9 -6
- package/lib/cache/resources/guilds.js +27 -6
- package/lib/cache/resources/members.d.ts +9 -6
- package/lib/cache/resources/members.js +24 -8
- package/lib/cache/resources/messages.d.ts +11 -7
- package/lib/cache/resources/messages.js +25 -11
- package/lib/cache/resources/overwrites.d.ts +11 -2
- package/lib/cache/resources/overwrites.js +9 -0
- package/lib/cache/resources/presence.d.ts +3 -2
- package/lib/cache/resources/roles.d.ts +9 -6
- package/lib/cache/resources/roles.js +13 -4
- package/lib/cache/resources/stage-instances.d.ts +2 -2
- package/lib/cache/resources/stickers.d.ts +9 -6
- package/lib/cache/resources/stickers.js +13 -4
- package/lib/cache/resources/threads.d.ts +9 -6
- package/lib/cache/resources/threads.js +13 -4
- package/lib/cache/resources/users.d.ts +9 -6
- package/lib/cache/resources/users.js +13 -4
- package/lib/cache/resources/voice-states.d.ts +11 -8
- package/lib/cache/resources/voice-states.js +15 -4
- package/lib/client/base.d.ts +32 -20
- package/lib/client/base.js +51 -30
- package/lib/client/client.d.ts +12 -9
- package/lib/client/client.js +43 -49
- package/lib/client/collectors.d.ts +36 -0
- package/lib/client/collectors.js +110 -0
- package/lib/client/httpclient.d.ts +8 -13
- package/lib/client/httpclient.js +27 -218
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +1 -0
- package/lib/client/transformers.d.ts +68 -0
- package/lib/client/transformers.js +99 -0
- package/lib/client/types.d.ts +5 -0
- package/lib/client/types.js +2 -0
- package/lib/client/workerclient.d.ts +18 -15
- package/lib/client/workerclient.js +148 -110
- package/lib/collection.d.ts +2 -2
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +40 -38
- package/lib/commands/applications/chat.js +22 -12
- package/lib/commands/applications/chatcontext.d.ts +17 -17
- package/lib/commands/applications/chatcontext.js +5 -5
- package/lib/commands/applications/menu.d.ts +9 -9
- package/lib/commands/applications/menu.js +5 -7
- package/lib/commands/applications/menucontext.d.ts +14 -13
- package/lib/commands/applications/menucontext.js +9 -9
- package/lib/commands/applications/options.d.ts +1 -1
- package/lib/commands/applications/options.js +20 -21
- package/lib/commands/applications/shared.d.ts +14 -0
- package/lib/commands/decorators.d.ts +47 -35
- package/lib/commands/decorators.js +19 -27
- package/lib/commands/handle.d.ts +64 -0
- package/lib/commands/handle.js +685 -0
- package/lib/commands/handler.d.ts +27 -18
- package/lib/commands/handler.js +296 -160
- package/lib/commands/optionresolver.d.ts +13 -13
- package/lib/commands/optionresolver.js +23 -28
- package/lib/common/bot/watcher.d.ts +4 -33
- package/lib/common/bot/watcher.js +0 -109
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +4 -1
- package/lib/common/it/colors.js +48 -49
- package/lib/common/it/formatter.d.ts +187 -0
- package/lib/common/it/formatter.js +226 -0
- package/lib/common/it/logger.d.ts +0 -1
- package/lib/common/it/logger.js +8 -8
- package/lib/common/it/utils.d.ts +15 -2
- package/lib/common/it/utils.js +80 -21
- package/lib/common/shorters/application.d.ts +56 -0
- package/lib/common/shorters/application.js +81 -0
- package/lib/common/shorters/bans.d.ts +42 -0
- package/lib/common/shorters/bans.js +78 -0
- package/lib/common/shorters/channels.d.ts +7 -6
- package/lib/common/shorters/channels.js +19 -15
- package/lib/common/shorters/emojis.d.ts +5 -6
- package/lib/common/shorters/emojis.js +8 -7
- package/lib/common/shorters/guilds.d.ts +18 -16
- package/lib/common/shorters/guilds.js +31 -26
- package/lib/common/shorters/interaction.d.ts +6 -6
- package/lib/common/shorters/interaction.js +12 -9
- package/lib/common/shorters/members.d.ts +29 -12
- package/lib/common/shorters/members.js +55 -16
- package/lib/common/shorters/messages.d.ts +7 -8
- package/lib/common/shorters/messages.js +10 -9
- package/lib/common/shorters/reactions.d.ts +3 -3
- package/lib/common/shorters/reactions.js +11 -11
- package/lib/common/shorters/roles.d.ts +9 -7
- package/lib/common/shorters/roles.js +26 -7
- package/lib/common/shorters/templates.d.ts +7 -8
- package/lib/common/shorters/templates.js +7 -7
- package/lib/common/shorters/threads.d.ts +6 -7
- package/lib/common/shorters/threads.js +6 -9
- package/lib/common/shorters/users.d.ts +4 -4
- package/lib/common/shorters/users.js +8 -4
- package/lib/common/shorters/webhook.d.ts +10 -10
- package/lib/common/shorters/webhook.js +12 -11
- package/lib/common/types/resolvables.d.ts +2 -2
- package/lib/common/types/util.d.ts +3 -1
- package/lib/common/types/write.d.ts +1 -1
- package/lib/components/ActionRow.d.ts +1 -1
- package/lib/components/BaseComponent.d.ts +1 -1
- package/lib/components/BaseComponent.js +1 -1
- package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
- package/lib/components/ButtonComponent.d.ts +17 -7
- package/lib/components/ButtonComponent.js +19 -2
- package/lib/components/ChannelSelectMenuComponent.d.ts +3 -3
- package/lib/components/MentionableSelectMenuComponent.d.ts +2 -2
- package/lib/components/RoleSelectMenuComponent.d.ts +2 -2
- package/lib/components/StringSelectMenuComponent.d.ts +2 -2
- package/lib/components/TextInputComponent.d.ts +2 -2
- package/lib/components/UserSelectMenuComponent.d.ts +2 -2
- package/lib/components/componentcommand.d.ts +3 -2
- package/lib/components/componentcommand.js +4 -3
- package/lib/components/componentcontext.d.ts +11 -10
- package/lib/components/componentcontext.js +8 -8
- package/lib/components/handler.d.ts +16 -15
- package/lib/components/handler.js +101 -108
- package/lib/components/index.d.ts +3 -3
- package/lib/components/index.js +12 -10
- package/lib/components/modalcommand.d.ts +2 -1
- package/lib/components/modalcommand.js +1 -0
- package/lib/components/modalcontext.d.ts +13 -12
- package/lib/components/modalcontext.js +2 -2
- package/lib/deps/mixer.d.ts +8 -0
- package/lib/deps/mixer.js +66 -0
- package/lib/events/event.d.ts +4 -3
- package/lib/events/handler.d.ts +40 -15
- package/lib/events/handler.js +99 -21
- package/lib/events/hooks/application_command.d.ts +2 -2
- package/lib/events/hooks/auto_moderation.d.ts +6 -7
- package/lib/events/hooks/auto_moderation.js +4 -4
- package/lib/events/hooks/channel.d.ts +2 -2
- package/lib/events/hooks/channel.js +4 -7
- package/lib/events/hooks/custom.d.ts +3 -3
- package/lib/events/hooks/dispatch.d.ts +3 -4
- package/lib/events/hooks/dispatch.js +2 -2
- package/lib/events/hooks/entitlement.d.ts +5 -37
- package/lib/events/hooks/entitlement.js +7 -7
- package/lib/events/hooks/guild.d.ts +126 -181
- package/lib/events/hooks/guild.js +13 -15
- package/lib/events/hooks/integration.d.ts +71 -15
- package/lib/events/hooks/integration.js +3 -3
- package/lib/events/hooks/interactions.d.ts +2 -2
- package/lib/events/hooks/invite.d.ts +18 -14
- package/lib/events/hooks/message.d.ts +72 -52
- package/lib/events/hooks/message.js +4 -8
- package/lib/events/hooks/presence.d.ts +21 -16
- package/lib/events/hooks/stage.d.ts +4 -4
- package/lib/events/hooks/thread.d.ts +140 -60
- package/lib/events/hooks/thread.js +4 -4
- package/lib/events/hooks/typing.d.ts +28 -5
- package/lib/events/hooks/typing.js +2 -2
- package/lib/events/hooks/user.d.ts +3 -3
- package/lib/events/hooks/user.js +2 -2
- package/lib/events/hooks/voice.d.ts +28 -3
- package/lib/events/hooks/voice.js +8 -4
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +6 -15
- package/lib/index.js +8 -12
- package/lib/langs/handler.d.ts +14 -10
- package/lib/langs/handler.js +40 -9
- package/lib/structures/AutoModerationRule.d.ts +4 -4
- package/lib/structures/AutoModerationRule.js +1 -2
- package/lib/structures/ClientUser.d.ts +1 -1
- package/lib/structures/Entitlement.d.ts +10 -0
- package/lib/structures/Entitlement.js +16 -0
- package/lib/structures/Guild.d.ts +37 -30
- package/lib/structures/Guild.js +7 -2
- package/lib/structures/GuildBan.d.ts +25 -0
- package/lib/structures/GuildBan.js +37 -0
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +3 -2
- package/lib/structures/GuildMember.d.ts +27 -19
- package/lib/structures/GuildMember.js +21 -11
- package/lib/structures/GuildPreview.d.ts +1 -1
- package/lib/structures/GuildRole.d.ts +5 -3
- package/lib/structures/GuildRole.js +8 -1
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +56 -38
- package/lib/structures/Interaction.js +134 -86
- package/lib/structures/Message.d.ts +80 -20
- package/lib/structures/Message.js +67 -26
- package/lib/structures/Poll.d.ts +4 -3
- package/lib/structures/Poll.js +6 -2
- package/lib/structures/Sticker.d.ts +10 -10
- package/lib/structures/Sticker.js +7 -7
- package/lib/structures/User.d.ts +6 -4
- package/lib/structures/User.js +6 -2
- package/lib/structures/VoiceState.d.ts +15 -11
- package/lib/structures/VoiceState.js +35 -17
- package/lib/structures/Webhook.d.ts +6 -7
- package/lib/structures/Webhook.js +6 -7
- package/lib/structures/channels.d.ts +14 -10
- package/lib/structures/channels.js +97 -62
- package/lib/structures/extra/BaseGuild.d.ts +1 -1
- package/lib/structures/extra/BaseGuild.js +3 -3
- package/lib/structures/extra/BitField.d.ts +1 -1
- package/lib/structures/extra/BitField.js +3 -2
- package/lib/structures/extra/DiscordBase.js +2 -2
- package/lib/structures/extra/Permissions.d.ts +3 -1
- package/lib/structures/extra/Permissions.js +8 -3
- package/lib/types/gateway.d.ts +1537 -0
- package/lib/types/gateway.js +4 -0
- package/lib/types/index.d.ts +9 -1
- package/lib/types/index.js +28 -1
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/base.d.ts +22 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/base.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.d.ts +4 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/channel.d.ts +7 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/channel.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/integer.d.ts +17 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/integer.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/number.d.ts +17 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/number.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/role.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/role.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +25 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +20 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/string.d.ts +17 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/string.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.d.ts +11 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.d.ts +11 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/user.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/user.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +60 -0
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.js +29 -0
- package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +65 -0
- package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/internals.d.ts +8 -0
- package/lib/types/payloads/_interactions/_applicationCommands/internals.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +54 -0
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +20 -0
- package/lib/types/payloads/_interactions/applicationCommands.d.ts +153 -0
- package/lib/types/payloads/_interactions/applicationCommands.js +61 -0
- package/lib/types/payloads/_interactions/autocomplete.d.ts +10 -0
- package/lib/types/payloads/_interactions/autocomplete.js +2 -0
- package/lib/types/payloads/_interactions/base.d.ts +197 -0
- package/lib/types/payloads/_interactions/base.js +2 -0
- package/lib/types/payloads/_interactions/messageComponents.d.ts +41 -0
- package/lib/types/payloads/_interactions/messageComponents.js +2 -0
- package/lib/types/payloads/_interactions/modalSubmit.d.ts +35 -0
- package/lib/types/payloads/_interactions/modalSubmit.js +2 -0
- package/lib/types/payloads/_interactions/ping.d.ts +3 -0
- package/lib/types/payloads/_interactions/ping.js +2 -0
- package/lib/types/payloads/_interactions/responses.d.ts +112 -0
- package/lib/types/payloads/_interactions/responses.js +54 -0
- package/lib/types/payloads/application.d.ts +292 -0
- package/lib/types/payloads/application.js +117 -0
- package/lib/types/payloads/auditLog.d.ts +644 -0
- package/lib/types/payloads/auditLog.js +80 -0
- package/lib/types/payloads/autoModeration.d.ts +219 -0
- package/lib/types/payloads/autoModeration.js +87 -0
- package/lib/types/payloads/channel.d.ts +1708 -0
- package/lib/types/payloads/channel.js +372 -0
- package/lib/types/payloads/emoji.d.ts +48 -0
- package/lib/types/payloads/emoji.js +5 -0
- package/lib/types/payloads/gateway.d.ts +373 -0
- package/lib/types/payloads/gateway.js +82 -0
- package/lib/types/payloads/guild.d.ts +1060 -0
- package/lib/types/payloads/guild.js +324 -0
- package/lib/types/payloads/guildScheduledEvent.d.ts +138 -0
- package/lib/types/payloads/guildScheduledEvent.js +32 -0
- package/lib/types/payloads/index.d.ts +64 -0
- package/lib/types/payloads/index.js +37 -0
- package/lib/types/payloads/interactions.d.ts +24 -0
- package/lib/types/payloads/interactions.js +23 -0
- package/lib/types/payloads/invite.d.ts +121 -0
- package/lib/types/payloads/invite.js +23 -0
- package/lib/types/payloads/monetization.d.ts +150 -0
- package/lib/types/payloads/monetization.js +79 -0
- package/lib/types/payloads/oauth2.d.ts +131 -0
- package/lib/types/payloads/oauth2.js +135 -0
- package/lib/types/payloads/permissions.d.ts +97 -0
- package/lib/types/payloads/permissions.js +16 -0
- package/lib/types/payloads/poll.d.ts +104 -0
- package/lib/types/payloads/poll.js +16 -0
- package/lib/types/payloads/stageInstance.d.ts +77 -0
- package/lib/types/payloads/stageInstance.js +19 -0
- package/lib/types/payloads/sticker.d.ts +123 -0
- package/lib/types/payloads/sticker.js +30 -0
- package/lib/types/payloads/teams.d.ts +78 -0
- package/lib/types/payloads/teams.js +23 -0
- package/lib/types/payloads/template.d.ts +62 -0
- package/lib/types/payloads/template.js +5 -0
- package/lib/types/payloads/user.d.ts +337 -0
- package/lib/types/payloads/user.js +167 -0
- package/lib/types/payloads/voice.d.ts +89 -0
- package/lib/types/payloads/voice.js +5 -0
- package/lib/types/payloads/webhook.d.ts +76 -0
- package/lib/types/payloads/webhook.js +21 -0
- package/lib/types/rest/application.d.ts +57 -0
- package/lib/types/rest/application.js +2 -0
- package/lib/types/rest/auditLog.d.ts +30 -0
- package/lib/types/rest/auditLog.js +2 -0
- package/lib/types/rest/autoModeration.d.ts +66 -0
- package/lib/types/rest/autoModeration.js +2 -0
- package/lib/types/rest/channel.d.ts +712 -0
- package/lib/types/rest/channel.js +11 -0
- package/lib/types/rest/emoji.d.ts +54 -0
- package/lib/types/rest/emoji.js +2 -0
- package/lib/types/rest/gateway.d.ts +9 -0
- package/lib/types/rest/gateway.js +2 -0
- package/lib/types/rest/guild.d.ts +865 -0
- package/lib/types/rest/guild.js +2 -0
- package/lib/types/rest/guildScheduledEvent.d.ts +126 -0
- package/lib/types/rest/guildScheduledEvent.js +2 -0
- package/lib/types/rest/index.d.ts +296 -0
- package/lib/types/rest/index.js +292 -0
- package/lib/types/rest/interactions.d.ts +194 -0
- package/lib/types/rest/interactions.js +2 -0
- package/lib/types/rest/invite.d.ts +24 -0
- package/lib/types/rest/invite.js +2 -0
- package/lib/types/rest/monetization.d.ts +82 -0
- package/lib/types/rest/monetization.js +11 -0
- package/lib/types/rest/oauth2.d.ts +172 -0
- package/lib/types/rest/oauth2.js +2 -0
- package/lib/types/rest/poll.d.ts +44 -0
- package/lib/types/rest/poll.js +2 -0
- package/lib/types/rest/stageInstance.d.ts +58 -0
- package/lib/types/rest/stageInstance.js +2 -0
- package/lib/types/rest/sticker.d.ts +77 -0
- package/lib/types/rest/sticker.js +2 -0
- package/lib/types/rest/template.d.ts +62 -0
- package/lib/types/rest/template.js +2 -0
- package/lib/types/rest/user.d.ts +120 -0
- package/lib/types/rest/user.js +2 -0
- package/lib/types/rest/voice.d.ts +17 -0
- package/lib/types/rest/voice.js +2 -0
- package/lib/types/rest/webhook.d.ts +250 -0
- package/lib/types/rest/webhook.js +2 -0
- package/lib/types/utils/index.d.ts +797 -0
- package/lib/types/utils/index.js +799 -0
- package/lib/websocket/SharedTypes.d.ts +4 -3
- package/lib/websocket/SharedTypes.js +1 -1
- package/lib/websocket/constants/index.d.ts +0 -1
- package/lib/websocket/discord/basesocket.d.ts +7 -6
- package/lib/websocket/discord/basesocket.js +35 -6
- package/lib/websocket/discord/events/memberUpdate.d.ts +1 -6
- package/lib/websocket/discord/events/memberUpdate.js +2 -1
- package/lib/websocket/discord/events/presenceUpdate.d.ts +5 -18
- package/lib/websocket/discord/events/presenceUpdate.js +5 -6
- package/lib/websocket/discord/shard.d.ts +9 -8
- package/lib/websocket/discord/shard.js +65 -47
- package/lib/websocket/discord/sharder.d.ts +6 -5
- package/lib/websocket/discord/sharder.js +11 -10
- package/lib/websocket/discord/shared.d.ts +13 -5
- package/lib/websocket/discord/socket/custom.d.ts +52 -0
- package/lib/websocket/discord/socket/custom.js +283 -0
- package/lib/websocket/discord/worker.d.ts +5 -10
- package/lib/websocket/discord/workermanager.d.ts +8 -15
- package/lib/websocket/discord/workermanager.js +35 -39
- package/lib/websocket/structures/index.d.ts +0 -1
- package/lib/websocket/structures/index.js +1 -1
- package/lib/websocket/structures/timeout.d.ts +0 -1
- package/package.json +65 -74
- package/lib/cache/adapters/redis.d.ts +0 -37
- package/lib/cache/adapters/redis.js +0 -218
- package/lib/client/oninteractioncreate.d.ts +0 -4
- package/lib/client/oninteractioncreate.js +0 -198
- package/lib/client/onmessagecreate.d.ts +0 -3
- package/lib/client/onmessagecreate.js +0 -395
- package/lib/structures/extra/functions.d.ts +0 -12
- package/lib/structures/extra/functions.js +0 -70
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type APIAuditLogEntry, type APIAutoModerationRule, type APIChannel, type APIEntitlement, type APIGuild, type APIGuildMember, type APIGuildScheduledEvent, type APIStageInstance, type APIUser, type GatewayActivity, type GatewayAutoModerationActionExecutionDispatchData, type GatewayChannelPinsUpdateDispatchData, type GatewayChannelUpdateDispatchData, GatewayDispatchEvents, type GatewayGuildBanAddDispatchData, type GatewayGuildBanRemoveDispatchData, type GatewayGuildCreateDispatchData, type GatewayGuildDeleteDispatchData, type GatewayGuildEmojisUpdateDispatchData, type GatewayGuildIntegrationsUpdateDispatchData, type GatewayGuildMemberRemoveDispatchData, type GatewayGuildMemberUpdateDispatchData, type GatewayGuildMembersChunkDispatchData, type GatewayGuildRoleCreateDispatchData, type GatewayGuildRoleDeleteDispatchData, type GatewayGuildRoleUpdateDispatchData, type GatewayGuildScheduledEventUserRemoveDispatchData, type GatewayGuildStickersUpdateDispatchData, type GatewayIntegrationCreateDispatchData, type GatewayIntegrationDeleteDispatchData, type GatewayInteractionCreateDispatchData, type GatewayInviteCreateDispatchData, type GatewayInviteDeleteDispatchData, type GatewayMessageCreateDispatchData, type GatewayMessageDeleteBulkDispatchData, type GatewayMessageDeleteDispatchData, type GatewayMessageReactionAddDispatchData, type GatewayMessageReactionRemoveAllDispatchData, type GatewayMessageReactionRemoveDispatchData, type GatewayMessageReactionRemoveEmojiDispatchData, type GatewayMessageUpdateDispatchData, type GatewayPresenceUpdateData, type GatewayPresenceUpdateDispatchData, type GatewayReadyDispatchData, type GatewayRequestGuildMembersDataWithQuery, type GatewayRequestGuildMembersDataWithUserIds, type GatewayThreadCreateDispatchData, type GatewayThreadDeleteDispatchData, type GatewayThreadListSyncDispatchData, type GatewayThreadMemberUpdateDispatchData, type GatewayThreadMembersUpdateDispatchData, type GatewayTypingStartDispatchData, type GatewayUserUpdateDispatchData, type GatewayVoiceServerUpdateDispatchData, type GatewayVoiceStateUpdateData, type GatewayWebhooksUpdateDispatchData, type PresenceUpdateStatus, type GatewayMessagePollVoteDispatchData } from 'discord-api-types/v10';
|
|
2
1
|
import type { RestToKeys } from '../common';
|
|
3
|
-
import type {
|
|
2
|
+
import type { GatewayActivity, PresenceUpdateStatus, GatewayPresenceUpdateData, GatewayRequestGuildMembersDataWithQuery, GatewayRequestGuildMembersDataWithUserIds, APIGuildMember, APIUser, GatewayReadyDispatchData, GatewayChannelUpdateDispatchData, GatewayAutoModerationActionExecutionDispatchData, GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayGuildCreateDispatchData, APIGuild, GatewayGuildDeleteDispatchData, APIAuditLogEntry, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberAddDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberUpdateDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayIntegrationDeleteDispatchData, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageCreateDispatchData, GatewayMessageUpdateDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayPresenceUpdateDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayVoiceStateUpdateData, GatewayVoiceServerUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewayInteractionCreateDispatchData, APIStageInstance, GatewayMessagePollVoteDispatchData, GatewayIntegrationCreateDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, APIGuildScheduledEvent, APIChannel, APIAutoModerationRule, APIEntitlement, GatewayVoiceChannelEffectSendDispachData } from '../types';
|
|
3
|
+
import { GatewayDispatchEvents } from '../types';
|
|
4
4
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
|
5
5
|
export interface StatusUpdate {
|
|
6
6
|
/** The user's activities */
|
|
@@ -55,7 +55,7 @@ export interface Events {
|
|
|
55
55
|
[GatewayDispatchEvents.GuildEmojisUpdate]: GatewayGuildEmojisUpdateDispatchData;
|
|
56
56
|
[GatewayDispatchEvents.GuildStickersUpdate]: GatewayGuildStickersUpdateDispatchData;
|
|
57
57
|
[GatewayDispatchEvents.GuildIntegrationsUpdate]: GatewayGuildIntegrationsUpdateDispatchData;
|
|
58
|
-
[GatewayDispatchEvents.GuildMemberAdd]:
|
|
58
|
+
[GatewayDispatchEvents.GuildMemberAdd]: GatewayGuildMemberAddDispatchData;
|
|
59
59
|
[GatewayDispatchEvents.GuildMemberRemove]: GatewayGuildMemberRemoveDispatchData;
|
|
60
60
|
[GatewayDispatchEvents.GuildMemberUpdate]: GatewayGuildMemberUpdateDispatchData;
|
|
61
61
|
[GatewayDispatchEvents.GuildMembersChunk]: GatewayGuildMembersChunkDispatchData;
|
|
@@ -76,6 +76,7 @@ export interface Events {
|
|
|
76
76
|
[GatewayDispatchEvents.PresenceUpdate]: GatewayPresenceUpdateDispatchData;
|
|
77
77
|
[GatewayDispatchEvents.TypingStart]: GatewayTypingStartDispatchData;
|
|
78
78
|
[GatewayDispatchEvents.UserUpdate]: GatewayUserUpdateDispatchData;
|
|
79
|
+
[GatewayDispatchEvents.VoiceChannelEffectSend]: GatewayVoiceChannelEffectSendDispachData;
|
|
79
80
|
[GatewayDispatchEvents.VoiceStateUpdate]: GatewayVoiceStateUpdateData;
|
|
80
81
|
[GatewayDispatchEvents.VoiceServerUpdate]: GatewayVoiceServerUpdateDispatchData;
|
|
81
82
|
[GatewayDispatchEvents.WebhooksUpdate]: GatewayWebhooksUpdateDispatchData;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SeyfertWebSocket } from './socket/custom';
|
|
2
2
|
export declare class BaseSocket {
|
|
3
3
|
private internal;
|
|
4
|
+
ping?: () => Promise<number>;
|
|
4
5
|
constructor(kind: 'ws' | 'bun', url: string);
|
|
5
|
-
set onopen(callback:
|
|
6
|
-
set onmessage(callback:
|
|
7
|
-
set onclose(callback:
|
|
8
|
-
set onerror(callback:
|
|
6
|
+
set onopen(callback: SeyfertWebSocket['onopen']);
|
|
7
|
+
set onmessage(callback: SeyfertWebSocket['onmessage']);
|
|
8
|
+
set onclose(callback: SeyfertWebSocket['onclose']);
|
|
9
|
+
set onerror(callback: SeyfertWebSocket['onerror']);
|
|
9
10
|
send(data: string): void;
|
|
10
|
-
close(...args: Parameters<
|
|
11
|
+
close(...args: Parameters<SeyfertWebSocket['close']>): void;
|
|
11
12
|
get readyState(): number;
|
|
12
13
|
}
|
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.BaseSocket = void 0;
|
|
7
|
-
const
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const custom_1 = require("./socket/custom");
|
|
8
6
|
class BaseSocket {
|
|
9
7
|
internal;
|
|
8
|
+
ping;
|
|
10
9
|
constructor(kind, url) {
|
|
11
|
-
this.internal = kind === 'ws' ? new
|
|
10
|
+
this.internal = kind === 'ws' ? new custom_1.SeyfertWebSocket(url) : new WebSocket(url);
|
|
11
|
+
if (kind === 'ws') {
|
|
12
|
+
const ws = this.internal;
|
|
13
|
+
this.ping = ws.waitPing.bind(ws);
|
|
14
|
+
ws.onpong = data => {
|
|
15
|
+
const promise = ws.__promises.get(data);
|
|
16
|
+
if (promise) {
|
|
17
|
+
ws.__promises.delete(data);
|
|
18
|
+
promise?.resolve();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const ws = this.internal;
|
|
24
|
+
this.ping = () => {
|
|
25
|
+
return new Promise(res => {
|
|
26
|
+
const nonce = (0, node_crypto_1.randomUUID)();
|
|
27
|
+
const start = performance.now();
|
|
28
|
+
const listener = (data) => {
|
|
29
|
+
if (data.toString() !== nonce)
|
|
30
|
+
return;
|
|
31
|
+
//@ts-expect-error
|
|
32
|
+
ws.removeListener('pong', listener);
|
|
33
|
+
res(performance.now() - start);
|
|
34
|
+
};
|
|
35
|
+
//@ts-expect-error
|
|
36
|
+
ws.on('pong', listener);
|
|
37
|
+
//@ts-expect-error
|
|
38
|
+
ws.ping(nonce);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|
|
12
42
|
}
|
|
13
43
|
set onopen(callback) {
|
|
14
44
|
this.internal.onopen = callback;
|
|
@@ -26,7 +56,6 @@ class BaseSocket {
|
|
|
26
56
|
return this.internal.send(data);
|
|
27
57
|
}
|
|
28
58
|
close(...args) {
|
|
29
|
-
// @ts-expect-error
|
|
30
59
|
return this.internal.close(...args);
|
|
31
60
|
}
|
|
32
61
|
get readyState() {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
import type { APIUser, GatewayGuildMemberUpdateDispatchData } from 'discord-api-types/v10';
|
|
1
|
+
import type { APIUser, GatewayGuildMemberUpdateDispatchData } from '../../../types';
|
|
7
2
|
export declare class MemberUpdateHandler {
|
|
8
3
|
guildMemberUpdate: Map<string, {
|
|
9
4
|
timeout: NodeJS.Timeout;
|
|
@@ -25,7 +25,8 @@ class MemberUpdateHandler {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
membersEquals(old, member) {
|
|
28
|
-
return (old.
|
|
28
|
+
return (old.guild_id === member.guild_id &&
|
|
29
|
+
old.joined_at === member.joined_at &&
|
|
29
30
|
old.nick === member.nick &&
|
|
30
31
|
old.avatar === member.avatar &&
|
|
31
32
|
old.pending === member.pending &&
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
import type { APIUser, GatewayActivity, GatewayPresenceUpdateDispatchData } from 'discord-api-types/v10';
|
|
7
|
-
type FixedGatewayPresenceUpdateDispatchData = (Omit<GatewayPresenceUpdateDispatchData, 'user'> & {
|
|
8
|
-
user_id: string;
|
|
9
|
-
user: undefined;
|
|
10
|
-
}) | (Omit<GatewayPresenceUpdateDispatchData, 'user'> & {
|
|
11
|
-
user: Partial<APIUser> & Pick<APIUser, 'id'>;
|
|
12
|
-
user_id: undefined;
|
|
13
|
-
});
|
|
1
|
+
import type { GatewayActivity, GatewayPresenceUpdateDispatchData } from '../../../types';
|
|
14
2
|
export declare class PresenceUpdateHandler {
|
|
15
3
|
presenceUpdate: Map<string, {
|
|
16
4
|
timeout: NodeJS.Timeout;
|
|
17
|
-
presence:
|
|
5
|
+
presence: GatewayPresenceUpdateDispatchData;
|
|
18
6
|
}>;
|
|
19
|
-
check(presence:
|
|
20
|
-
setPresence(presence:
|
|
21
|
-
presenceEquals(oldPresence:
|
|
7
|
+
check(presence: GatewayPresenceUpdateDispatchData): boolean;
|
|
8
|
+
setPresence(presence: GatewayPresenceUpdateDispatchData): void;
|
|
9
|
+
presenceEquals(oldPresence: GatewayPresenceUpdateDispatchData, newPresence: GatewayPresenceUpdateDispatchData): boolean | undefined;
|
|
22
10
|
activityEquals(oldActivity: GatewayActivity, newActivity: GatewayActivity): boolean;
|
|
23
11
|
}
|
|
24
|
-
export {};
|
|
@@ -4,11 +4,11 @@ exports.PresenceUpdateHandler = void 0;
|
|
|
4
4
|
class PresenceUpdateHandler {
|
|
5
5
|
presenceUpdate = new Map();
|
|
6
6
|
check(presence) {
|
|
7
|
-
if (!this.presenceUpdate.has(presence.user
|
|
7
|
+
if (!this.presenceUpdate.has(presence.user.id)) {
|
|
8
8
|
this.setPresence(presence);
|
|
9
9
|
return true;
|
|
10
10
|
}
|
|
11
|
-
const data = this.presenceUpdate.get(presence.user
|
|
11
|
+
const data = this.presenceUpdate.get(presence.user.id);
|
|
12
12
|
if (this.presenceEquals(data.presence, presence)) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
@@ -17,16 +17,15 @@ class PresenceUpdateHandler {
|
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
setPresence(presence) {
|
|
20
|
-
this.presenceUpdate.set(presence.user
|
|
20
|
+
this.presenceUpdate.set(presence.user.id, {
|
|
21
21
|
presence,
|
|
22
22
|
timeout: setTimeout(() => {
|
|
23
|
-
this.presenceUpdate.delete(presence.user
|
|
23
|
+
this.presenceUpdate.delete(presence.user.id);
|
|
24
24
|
}, 1.5e3),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
presenceEquals(oldPresence, newPresence) {
|
|
28
|
-
return (newPresence &&
|
|
29
|
-
oldPresence.status === newPresence.status &&
|
|
28
|
+
return (oldPresence.status === newPresence.status &&
|
|
30
29
|
oldPresence.activities?.length === newPresence.activities?.length &&
|
|
31
30
|
oldPresence.activities?.every((activity, index) => this.activityEquals(activity, newPresence.activities?.[index])) &&
|
|
32
31
|
oldPresence.client_status?.web === newPresence.client_status?.web &&
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import type { GatewayReceivePayload, GatewaySendPayload } from 'discord-api-types/v10';
|
|
3
|
-
import type WS from 'ws';
|
|
4
|
-
import { type CloseEvent } from 'ws';
|
|
5
|
-
import type { Logger } from '../../common';
|
|
1
|
+
import { type MakeRequired, type Logger } from '../../common';
|
|
6
2
|
import { DynamicBucket } from '../structures';
|
|
7
3
|
import { ConnectTimeout } from '../structures/timeout';
|
|
8
4
|
import { BaseSocket } from './basesocket';
|
|
9
5
|
import type { ShardData, ShardOptions } from './shared';
|
|
6
|
+
import { type GatewaySendPayload, type GatewayReceivePayload } from '../../types';
|
|
10
7
|
export interface ShardHeart {
|
|
11
8
|
interval: number;
|
|
12
9
|
nodeInterval?: NodeJS.Timeout;
|
|
@@ -16,7 +13,6 @@ export interface ShardHeart {
|
|
|
16
13
|
}
|
|
17
14
|
export declare class Shard {
|
|
18
15
|
id: number;
|
|
19
|
-
options: ShardOptions;
|
|
20
16
|
debugger?: Logger;
|
|
21
17
|
data: Partial<ShardData> | ShardData;
|
|
22
18
|
websocket: BaseSocket | null;
|
|
@@ -24,12 +20,14 @@ export declare class Shard {
|
|
|
24
20
|
heart: ShardHeart;
|
|
25
21
|
bucket: DynamicBucket;
|
|
26
22
|
offlineSendQueue: ((_?: unknown) => void)[];
|
|
23
|
+
options: MakeRequired<ShardOptions, 'properties' | 'ratelimitOptions'>;
|
|
27
24
|
constructor(id: number, options: ShardOptions);
|
|
28
25
|
get latency(): number;
|
|
29
26
|
get isOpen(): boolean;
|
|
30
27
|
get gatewayURL(): string;
|
|
31
28
|
get resumeGatewayURL(): string | undefined;
|
|
32
29
|
get currentGatewayURL(): string;
|
|
30
|
+
ping(): Promise<number>;
|
|
33
31
|
connect(): Promise<void>;
|
|
34
32
|
send<T extends GatewaySendPayload = GatewaySendPayload>(force: boolean, message: T): Promise<void>;
|
|
35
33
|
identify(): Promise<void>;
|
|
@@ -39,9 +37,12 @@ export declare class Shard {
|
|
|
39
37
|
disconnect(): Promise<void>;
|
|
40
38
|
reconnect(): Promise<void>;
|
|
41
39
|
onpacket(packet: GatewayReceivePayload): Promise<void>;
|
|
42
|
-
protected handleClosed(close:
|
|
40
|
+
protected handleClosed(close: {
|
|
41
|
+
code: number;
|
|
42
|
+
reason: string;
|
|
43
|
+
}): Promise<void>;
|
|
43
44
|
close(code: number, reason: string): Promise<void>;
|
|
44
|
-
protected handleMessage(
|
|
45
|
+
protected handleMessage(data: string | Buffer): Promise<void>;
|
|
45
46
|
checkOffline(force: boolean): Promise<unknown>;
|
|
46
47
|
calculateSafeRequests(): number;
|
|
47
48
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Shard = void 0;
|
|
4
|
-
const v10_1 = require("discord-api-types/v10");
|
|
5
4
|
const node_zlib_1 = require("node:zlib");
|
|
6
|
-
const
|
|
5
|
+
const common_1 = require("../../common");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
8
7
|
const structures_1 = require("../structures");
|
|
9
8
|
const timeout_1 = require("../structures/timeout");
|
|
10
9
|
const basesocket_1 = require("./basesocket");
|
|
11
10
|
const shared_1 = require("./shared");
|
|
11
|
+
const types_1 = require("../../types");
|
|
12
12
|
class Shard {
|
|
13
13
|
id;
|
|
14
|
-
options;
|
|
15
14
|
debugger;
|
|
16
15
|
data = {
|
|
17
|
-
|
|
16
|
+
resume_seq: null,
|
|
18
17
|
};
|
|
19
18
|
websocket = null;
|
|
20
19
|
connectTimeout = new timeout_1.ConnectTimeout();
|
|
@@ -24,13 +23,16 @@ class Shard {
|
|
|
24
23
|
};
|
|
25
24
|
bucket;
|
|
26
25
|
offlineSendQueue = [];
|
|
26
|
+
options;
|
|
27
27
|
constructor(id, options) {
|
|
28
28
|
this.id = id;
|
|
29
|
-
this.options = options
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
this.options = (0, common_1.MergeOptions)(options, {
|
|
30
|
+
properties: constants_1.properties,
|
|
31
|
+
ratelimitOptions: {
|
|
32
|
+
rateLimitResetInterval: 60_000,
|
|
33
|
+
maxRequestsPerRateLimitTick: 120,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
34
36
|
if (options.debugger)
|
|
35
37
|
this.debugger = options.debugger;
|
|
36
38
|
const safe = this.calculateSafeRequests();
|
|
@@ -42,7 +44,7 @@ class Shard {
|
|
|
42
44
|
: Number.POSITIVE_INFINITY;
|
|
43
45
|
}
|
|
44
46
|
get isOpen() {
|
|
45
|
-
return this.websocket?.readyState ===
|
|
47
|
+
return this.websocket?.readyState === 1 /*WebSocket.open*/;
|
|
46
48
|
}
|
|
47
49
|
get gatewayURL() {
|
|
48
50
|
return this.options.info.url;
|
|
@@ -55,16 +57,26 @@ class Shard {
|
|
|
55
57
|
url.searchParams.set('v', '10');
|
|
56
58
|
return url.href;
|
|
57
59
|
}
|
|
60
|
+
ping() {
|
|
61
|
+
if (!this.websocket)
|
|
62
|
+
return Promise.resolve(Number.POSITIVE_INFINITY);
|
|
63
|
+
//@ts-expect-error
|
|
64
|
+
return this.websocket.ping();
|
|
65
|
+
}
|
|
58
66
|
async connect() {
|
|
59
67
|
await this.connectTimeout.wait();
|
|
60
68
|
if (this.isOpen) {
|
|
61
69
|
this.debugger?.debug(`[Shard #${this.id}] attempted to connect while open`);
|
|
62
70
|
return;
|
|
63
71
|
}
|
|
72
|
+
clearTimeout(this.heart.nodeInterval);
|
|
64
73
|
this.debugger?.debug(`[Shard #${this.id}] Connecting to ${this.currentGatewayURL}`);
|
|
65
74
|
// @ts-expect-error @types/bun cause erros in compile
|
|
75
|
+
// biome-ignore lint/correctness/noUndeclaredVariables: /\ bun lol
|
|
66
76
|
this.websocket = new basesocket_1.BaseSocket(typeof Bun === 'undefined' ? 'ws' : 'bun', this.currentGatewayURL);
|
|
67
|
-
this.websocket.onmessage = (
|
|
77
|
+
this.websocket.onmessage = ({ data }) => {
|
|
78
|
+
this.handleMessage(data);
|
|
79
|
+
};
|
|
68
80
|
this.websocket.onclose = (event) => this.handleClosed(event);
|
|
69
81
|
this.websocket.onerror = (event) => this.debugger?.error(event);
|
|
70
82
|
this.websocket.onopen = () => {
|
|
@@ -72,7 +84,7 @@ class Shard {
|
|
|
72
84
|
};
|
|
73
85
|
}
|
|
74
86
|
async send(force, message) {
|
|
75
|
-
this.debugger?.info(`[Shard #${this.id}] Sending: ${
|
|
87
|
+
this.debugger?.info(`[Shard #${this.id}] Sending: ${types_1.GatewayOpcodes[message.op]} ${JSON.stringify(message.d, (_, value) => {
|
|
76
88
|
if (typeof value === 'string')
|
|
77
89
|
return value.replaceAll(this.options.token, v => {
|
|
78
90
|
const split = v.split('.');
|
|
@@ -87,11 +99,11 @@ class Shard {
|
|
|
87
99
|
}
|
|
88
100
|
async identify() {
|
|
89
101
|
await this.send(true, {
|
|
90
|
-
op:
|
|
102
|
+
op: types_1.GatewayOpcodes.Identify,
|
|
91
103
|
d: {
|
|
92
104
|
token: `Bot ${this.options.token}`,
|
|
93
105
|
compress: this.options.compress,
|
|
94
|
-
properties: this.options.properties
|
|
106
|
+
properties: this.options.properties,
|
|
95
107
|
shard: [this.id, this.options.info.shards],
|
|
96
108
|
intents: this.options.intents,
|
|
97
109
|
presence: this.options.presence,
|
|
@@ -99,13 +111,13 @@ class Shard {
|
|
|
99
111
|
});
|
|
100
112
|
}
|
|
101
113
|
get resumable() {
|
|
102
|
-
return !!(this.data.resume_gateway_url && this.data.session_id && this.data.
|
|
114
|
+
return !!(this.data.resume_gateway_url && this.data.session_id && this.data.resume_seq !== null);
|
|
103
115
|
}
|
|
104
116
|
async resume() {
|
|
105
117
|
await this.send(true, {
|
|
106
|
-
op:
|
|
118
|
+
op: types_1.GatewayOpcodes.Resume,
|
|
107
119
|
d: {
|
|
108
|
-
seq: this.data.
|
|
120
|
+
seq: this.data.resume_seq,
|
|
109
121
|
session_id: this.data.session_id,
|
|
110
122
|
token: `Bot ${this.options.token}`,
|
|
111
123
|
},
|
|
@@ -122,8 +134,8 @@ class Shard {
|
|
|
122
134
|
}
|
|
123
135
|
this.heart.lastBeat = Date.now();
|
|
124
136
|
this.websocket.send(JSON.stringify({
|
|
125
|
-
op:
|
|
126
|
-
d: this.data.
|
|
137
|
+
op: types_1.GatewayOpcodes.Heartbeat,
|
|
138
|
+
d: this.data.resume_seq ?? null,
|
|
127
139
|
}));
|
|
128
140
|
}
|
|
129
141
|
async disconnect() {
|
|
@@ -137,11 +149,11 @@ class Shard {
|
|
|
137
149
|
}
|
|
138
150
|
async onpacket(packet) {
|
|
139
151
|
if (packet.s !== null) {
|
|
140
|
-
this.data.
|
|
152
|
+
this.data.resume_seq = packet.s;
|
|
141
153
|
}
|
|
142
|
-
this.debugger?.debug(`[Shard #${this.id}]`, packet.t ? packet.t :
|
|
154
|
+
this.debugger?.debug(`[Shard #${this.id}]`, packet.t ? packet.t : types_1.GatewayOpcodes[packet.op], this.data.resume_seq);
|
|
143
155
|
switch (packet.op) {
|
|
144
|
-
case
|
|
156
|
+
case types_1.GatewayOpcodes.Hello:
|
|
145
157
|
{
|
|
146
158
|
clearInterval(this.heart.nodeInterval);
|
|
147
159
|
this.heart.interval = packet.d.heartbeat_interval;
|
|
@@ -153,17 +165,17 @@ class Shard {
|
|
|
153
165
|
await this.identify();
|
|
154
166
|
}
|
|
155
167
|
break;
|
|
156
|
-
case
|
|
168
|
+
case types_1.GatewayOpcodes.HeartbeatAck:
|
|
157
169
|
this.heart.ack = true;
|
|
158
170
|
this.heart.lastAck = Date.now();
|
|
159
171
|
break;
|
|
160
|
-
case
|
|
172
|
+
case types_1.GatewayOpcodes.Heartbeat:
|
|
161
173
|
this.heartbeat(true);
|
|
162
174
|
break;
|
|
163
|
-
case
|
|
175
|
+
case types_1.GatewayOpcodes.Reconnect:
|
|
164
176
|
await this.reconnect();
|
|
165
177
|
break;
|
|
166
|
-
case
|
|
178
|
+
case types_1.GatewayOpcodes.InvalidSession:
|
|
167
179
|
if (packet.d) {
|
|
168
180
|
if (!this.resumable) {
|
|
169
181
|
return this.debugger?.fatal(`[Shard #${this.id}] This is a completely unexpected error message.`);
|
|
@@ -171,19 +183,19 @@ class Shard {
|
|
|
171
183
|
await this.resume();
|
|
172
184
|
}
|
|
173
185
|
else {
|
|
174
|
-
this.data.
|
|
186
|
+
this.data.resume_seq = 0;
|
|
175
187
|
this.data.session_id = undefined;
|
|
176
188
|
await this.identify();
|
|
177
189
|
}
|
|
178
190
|
break;
|
|
179
|
-
case
|
|
191
|
+
case types_1.GatewayOpcodes.Dispatch:
|
|
180
192
|
{
|
|
181
193
|
switch (packet.t) {
|
|
182
|
-
case
|
|
194
|
+
case types_1.GatewayDispatchEvents.Resumed:
|
|
183
195
|
this.offlineSendQueue.map((resolve) => resolve());
|
|
184
196
|
this.options.handlePayload(this.id, packet);
|
|
185
197
|
break;
|
|
186
|
-
case
|
|
198
|
+
case types_1.GatewayDispatchEvents.Ready: {
|
|
187
199
|
this.data.resume_gateway_url = packet.d.resume_gateway_url;
|
|
188
200
|
this.data.session_id = packet.d.session_id;
|
|
189
201
|
this.offlineSendQueue.map((resolve) => resolve());
|
|
@@ -200,31 +212,37 @@ class Shard {
|
|
|
200
212
|
}
|
|
201
213
|
async handleClosed(close) {
|
|
202
214
|
clearInterval(this.heart.nodeInterval);
|
|
203
|
-
this.debugger?.warn(`[Shard #${this.id}] ${shared_1.ShardSocketCloseCodes[close.code] ??
|
|
215
|
+
this.debugger?.warn(`[Shard #${this.id}] ${shared_1.ShardSocketCloseCodes[close.code] ?? types_1.GatewayCloseCodes[close.code] ?? close.code} (${close.code})`, close.reason);
|
|
204
216
|
switch (close.code) {
|
|
205
217
|
case shared_1.ShardSocketCloseCodes.Shutdown:
|
|
218
|
+
//Force disconnect, ignore
|
|
206
219
|
break;
|
|
207
220
|
case 1000:
|
|
221
|
+
case types_1.GatewayCloseCodes.UnknownOpcode:
|
|
222
|
+
case types_1.GatewayCloseCodes.InvalidSeq:
|
|
223
|
+
case types_1.GatewayCloseCodes.SessionTimedOut:
|
|
224
|
+
this.data.resume_seq = 0;
|
|
225
|
+
this.data.session_id = undefined;
|
|
226
|
+
this.data.resume_gateway_url = undefined;
|
|
227
|
+
await this.reconnect();
|
|
228
|
+
break;
|
|
208
229
|
case 1001:
|
|
209
230
|
case 1006:
|
|
210
231
|
case shared_1.ShardSocketCloseCodes.ZombiedConnection:
|
|
211
|
-
case
|
|
212
|
-
case
|
|
213
|
-
case
|
|
214
|
-
case
|
|
215
|
-
case
|
|
216
|
-
case v10_1.GatewayCloseCodes.InvalidSeq:
|
|
217
|
-
case v10_1.GatewayCloseCodes.RateLimited:
|
|
218
|
-
case v10_1.GatewayCloseCodes.SessionTimedOut:
|
|
232
|
+
case types_1.GatewayCloseCodes.UnknownError:
|
|
233
|
+
case types_1.GatewayCloseCodes.DecodeError:
|
|
234
|
+
case types_1.GatewayCloseCodes.NotAuthenticated:
|
|
235
|
+
case types_1.GatewayCloseCodes.AlreadyAuthenticated:
|
|
236
|
+
case types_1.GatewayCloseCodes.RateLimited:
|
|
219
237
|
this.debugger?.info(`[Shard #${this.id}] Trying to reconnect`);
|
|
220
238
|
await this.reconnect();
|
|
221
239
|
break;
|
|
222
|
-
case
|
|
223
|
-
case
|
|
224
|
-
case
|
|
225
|
-
case
|
|
226
|
-
case
|
|
227
|
-
case
|
|
240
|
+
case types_1.GatewayCloseCodes.AuthenticationFailed:
|
|
241
|
+
case types_1.GatewayCloseCodes.DisallowedIntents:
|
|
242
|
+
case types_1.GatewayCloseCodes.InvalidAPIVersion:
|
|
243
|
+
case types_1.GatewayCloseCodes.InvalidIntents:
|
|
244
|
+
case types_1.GatewayCloseCodes.InvalidShard:
|
|
245
|
+
case types_1.GatewayCloseCodes.ShardingRequired:
|
|
228
246
|
this.debugger?.fatal(`[Shard #${this.id}] cannot reconnect`);
|
|
229
247
|
break;
|
|
230
248
|
default:
|
|
@@ -234,13 +252,13 @@ class Shard {
|
|
|
234
252
|
}
|
|
235
253
|
}
|
|
236
254
|
async close(code, reason) {
|
|
237
|
-
if (this.
|
|
255
|
+
if (!this.isOpen) {
|
|
238
256
|
return this.debugger?.warn(`[Shard #${this.id}] Is not open`);
|
|
239
257
|
}
|
|
240
258
|
this.debugger?.warn(`[Shard #${this.id}] Called close`);
|
|
241
259
|
this.websocket?.close(code, reason);
|
|
242
260
|
}
|
|
243
|
-
handleMessage(
|
|
261
|
+
handleMessage(data) {
|
|
244
262
|
if (data instanceof Buffer) {
|
|
245
263
|
data = (0, node_zlib_1.inflateSync)(data);
|
|
246
264
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Logger, type MakeRequired } from '../../common';
|
|
2
|
+
import { type GatewayUpdatePresence, type GatewayVoiceStateUpdate, type GatewaySendPayload } from '../../types';
|
|
3
|
+
import { ShardManagerDefaults } from '../constants';
|
|
3
4
|
import { ConnectQueue } from '../structures/timeout';
|
|
4
|
-
import { Shard } from './shard
|
|
5
|
+
import { Shard } from './shard';
|
|
5
6
|
import type { ShardManagerOptions } from './shared';
|
|
6
7
|
export declare class ShardManager extends Map<number, Shard> {
|
|
7
8
|
connectQueue: ConnectQueue;
|
|
8
|
-
options: ShardManagerOptions
|
|
9
|
+
options: MakeRequired<ShardManagerOptions, keyof typeof ShardManagerDefaults>;
|
|
9
10
|
debugger?: Logger;
|
|
10
11
|
constructor(options: ShardManagerOptions);
|
|
11
12
|
get totalShards(): number;
|
|
@@ -23,7 +24,7 @@ export declare class ShardManager extends Map<number, Shard> {
|
|
|
23
24
|
disconnectAll(): Promise<unknown>;
|
|
24
25
|
setShardPresence(shardId: number, payload: GatewayUpdatePresence['d']): void;
|
|
25
26
|
setPresence(payload: GatewayUpdatePresence['d']): Promise<void>;
|
|
26
|
-
joinVoice(guild_id: string, channel_id: string, options:
|
|
27
|
+
joinVoice(guild_id: string, channel_id: string, options: Pick<GatewayVoiceStateUpdate['d'], 'self_deaf' | 'self_mute'>): void;
|
|
27
28
|
leaveVoice(guild_id: string): void;
|
|
28
29
|
send<T extends GatewaySendPayload>(shardId: number, payload: T): void;
|
|
29
30
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShardManager = void 0;
|
|
4
|
-
const v10_1 = require("discord-api-types/v10");
|
|
5
4
|
const common_1 = require("../../common");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const structures_1 = require("../structures");
|
|
8
8
|
const timeout_1 = require("../structures/timeout");
|
|
9
|
-
const
|
|
9
|
+
const shard_1 = require("./shard");
|
|
10
10
|
let parentPort;
|
|
11
11
|
let workerData;
|
|
12
12
|
class ShardManager extends Map {
|
|
@@ -15,8 +15,9 @@ class ShardManager extends Map {
|
|
|
15
15
|
debugger;
|
|
16
16
|
constructor(options) {
|
|
17
17
|
super();
|
|
18
|
-
options
|
|
19
|
-
|
|
18
|
+
this.options = (0, common_1.MergeOptions)(constants_1.ShardManagerDefaults, {
|
|
19
|
+
totalShards: options.info.shards,
|
|
20
|
+
}, options);
|
|
20
21
|
this.connectQueue = new timeout_1.ConnectQueue(5.5e3, this.concurrency);
|
|
21
22
|
if (this.options.debug) {
|
|
22
23
|
this.debugger = new common_1.Logger({
|
|
@@ -57,14 +58,14 @@ class ShardManager extends Map {
|
|
|
57
58
|
spawn(shardId) {
|
|
58
59
|
this.debugger?.info(`Spawn shard ${shardId}`);
|
|
59
60
|
let shard = this.get(shardId);
|
|
60
|
-
shard ??= new
|
|
61
|
+
shard ??= new shard_1.Shard(shardId, {
|
|
61
62
|
token: this.options.token,
|
|
62
63
|
intents: this.options.intents,
|
|
63
64
|
info: { ...this.options.info, shards: this.totalShards },
|
|
64
65
|
handlePayload: this.options.handlePayload,
|
|
65
66
|
properties: this.options.properties,
|
|
66
67
|
debugger: this.debugger,
|
|
67
|
-
compress: false,
|
|
68
|
+
compress: this.options.compress ?? false,
|
|
68
69
|
presence: this.options.presence?.(shardId, -1),
|
|
69
70
|
});
|
|
70
71
|
this.set(shardId, shard);
|
|
@@ -117,7 +118,7 @@ class ShardManager extends Map {
|
|
|
117
118
|
setShardPresence(shardId, payload) {
|
|
118
119
|
this.debugger?.info(`Shard #${shardId} update presence`);
|
|
119
120
|
return this.send(shardId, {
|
|
120
|
-
op:
|
|
121
|
+
op: types_1.GatewayOpcodes.PresenceUpdate,
|
|
121
122
|
d: payload,
|
|
122
123
|
});
|
|
123
124
|
}
|
|
@@ -133,11 +134,11 @@ class ShardManager extends Map {
|
|
|
133
134
|
const shardId = this.calculateShardId(guild_id);
|
|
134
135
|
this.debugger?.info(`Shard #${shardId} join voice ${channel_id} in ${guild_id}`);
|
|
135
136
|
return this.send(shardId, {
|
|
136
|
-
op:
|
|
137
|
+
op: types_1.GatewayOpcodes.VoiceStateUpdate,
|
|
137
138
|
d: {
|
|
138
139
|
guild_id,
|
|
139
140
|
channel_id,
|
|
140
|
-
...
|
|
141
|
+
...options,
|
|
141
142
|
},
|
|
142
143
|
});
|
|
143
144
|
}
|
|
@@ -145,7 +146,7 @@ class ShardManager extends Map {
|
|
|
145
146
|
const shardId = this.calculateShardId(guild_id);
|
|
146
147
|
this.debugger?.info(`Shard #${shardId} leave voice in ${guild_id}`);
|
|
147
148
|
return this.send(shardId, {
|
|
148
|
-
op:
|
|
149
|
+
op: types_1.GatewayOpcodes.VoiceStateUpdate,
|
|
149
150
|
d: {
|
|
150
151
|
guild_id,
|
|
151
152
|
channel_id: null,
|