seyfert 1.5.0 → 2.1.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 +18 -10
- package/lib/api/Router.js +2 -2
- 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 +5 -2
- package/lib/api/Routes/interactions.d.ts +8 -2
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/skus.d.ts +11 -0
- package/lib/api/Routes/skus.js +2 -0
- 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 +3 -3
- package/lib/api/api.js +15 -25
- package/lib/api/bucket.d.ts +0 -1
- package/lib/api/shared.d.ts +1 -2
- 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 +3 -4
- package/lib/builders/Attachment.js +24 -25
- 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 +20 -8
- package/lib/cache/index.js +328 -22
- package/lib/cache/resources/bans.d.ts +9 -6
- package/lib/cache/resources/bans.js +13 -4
- 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 +22 -6
- package/lib/cache/resources/messages.d.ts +11 -7
- package/lib/cache/resources/messages.js +19 -7
- 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 +29 -21
- package/lib/client/base.js +64 -57
- package/lib/client/client.d.ts +11 -16
- package/lib/client/client.js +51 -37
- package/lib/client/collectors.d.ts +10 -10
- package/lib/client/collectors.js +26 -1
- 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 +16 -15
- package/lib/client/workerclient.js +130 -72
- package/lib/commands/applications/chat.d.ts +35 -34
- package/lib/commands/applications/chat.js +5 -9
- package/lib/commands/applications/chatcontext.d.ts +17 -17
- package/lib/commands/applications/chatcontext.js +5 -5
- package/lib/commands/applications/entryPoint.d.ts +46 -0
- package/lib/commands/applications/entryPoint.js +56 -0
- package/lib/commands/applications/entrycontext.d.ts +40 -0
- package/lib/commands/applications/entrycontext.js +85 -0
- package/lib/commands/applications/menu.d.ts +2 -3
- package/lib/commands/applications/menu.js +2 -5
- package/lib/commands/applications/menucontext.d.ts +14 -13
- package/lib/commands/applications/menucontext.js +9 -9
- package/lib/commands/applications/options.d.ts +4 -3
- package/lib/commands/applications/options.js +20 -21
- package/lib/commands/applications/shared.d.ts +3 -1
- package/lib/commands/decorators.d.ts +47 -35
- package/lib/commands/decorators.js +20 -18
- package/lib/commands/handle.d.ts +65 -0
- package/lib/commands/handle.js +727 -0
- package/lib/commands/handler.d.ts +29 -18
- package/lib/commands/handler.js +295 -164
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/optionresolver.d.ts +13 -13
- package/lib/commands/optionresolver.js +24 -29
- package/lib/common/bot/watcher.d.ts +4 -33
- package/lib/common/bot/watcher.js +0 -109
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/it/colors.js +48 -49
- package/lib/common/it/formatter.d.ts +32 -0
- package/lib/common/it/formatter.js +42 -0
- package/lib/common/it/logger.d.ts +0 -1
- package/lib/common/it/logger.js +3 -3
- package/lib/common/it/utils.d.ts +24 -4
- package/lib/common/it/utils.js +88 -17
- package/lib/common/shorters/application.d.ts +56 -0
- package/lib/common/shorters/application.js +81 -0
- package/lib/common/shorters/bans.d.ts +4 -5
- package/lib/common/shorters/bans.js +3 -3
- 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 +5 -5
- package/lib/common/shorters/guilds.d.ts +18 -16
- package/lib/common/shorters/guilds.js +31 -26
- package/lib/common/shorters/interaction.d.ts +7 -7
- package/lib/common/shorters/interaction.js +3 -2
- 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 +8 -7
- 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 +10 -9
- package/lib/common/types/resolvables.d.ts +2 -2
- package/lib/common/types/util.d.ts +4 -2
- package/lib/common/types/write.d.ts +3 -3
- 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.js +2 -2
- package/lib/components/componentcontext.d.ts +10 -9
- package/lib/components/componentcontext.js +8 -8
- package/lib/components/handler.d.ts +15 -14
- package/lib/components/handler.js +89 -93
- package/lib/components/index.d.ts +3 -3
- package/lib/components/index.js +12 -10
- package/lib/components/modalcontext.d.ts +12 -11
- package/lib/components/modalcontext.js +2 -2
- package/lib/deps/mixer.d.ts +8 -0
- package/lib/deps/mixer.js +71 -0
- package/lib/events/handler.d.ts +35 -13
- package/lib/events/handler.js +57 -24
- 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 +4 -3
- package/lib/events/hooks/custom.js +5 -1
- 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 +125 -125
- package/lib/events/hooks/guild.js +13 -15
- package/lib/events/hooks/integration.d.ts +27 -28
- 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 -17
- package/lib/events/hooks/message.d.ts +69 -54
- package/lib/events/hooks/message.js +4 -8
- package/lib/events/hooks/presence.d.ts +17 -16
- package/lib/events/hooks/stage.d.ts +4 -4
- package/lib/events/hooks/subscriptions.d.ts +35 -0
- package/lib/events/hooks/subscriptions.js +16 -0
- package/lib/events/hooks/thread.d.ts +132 -63
- package/lib/events/hooks/thread.js +4 -4
- package/lib/events/hooks/typing.d.ts +28 -6
- 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 +5 -14
- package/lib/index.js +7 -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 +33 -34
- package/lib/structures/Guild.js +5 -2
- package/lib/structures/GuildBan.d.ts +6 -6
- package/lib/structures/GuildBan.js +2 -1
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +3 -2
- package/lib/structures/GuildMember.d.ts +20 -17
- package/lib/structures/GuildMember.js +18 -8
- 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 +76 -39
- package/lib/structures/Interaction.js +179 -94
- package/lib/structures/Message.d.ts +29 -33
- package/lib/structures/Message.js +8 -12
- package/lib/structures/Poll.d.ts +4 -3
- package/lib/structures/Poll.js +6 -2
- package/lib/structures/Sticker.d.ts +7 -7
- package/lib/structures/Sticker.js +7 -7
- package/lib/structures/User.d.ts +5 -4
- package/lib/structures/User.js +2 -1
- 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 +11 -10
- package/lib/structures/channels.js +70 -65
- package/lib/structures/extra/BaseGuild.d.ts +12 -2
- package/lib/structures/extra/BaseGuild.js +30 -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 +1554 -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 +65 -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 +188 -0
- package/lib/types/payloads/_interactions/applicationCommands.js +88 -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 +184 -0
- package/lib/types/payloads/_interactions/responses.js +58 -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 +1748 -0
- package/lib/types/payloads/channel.js +376 -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 +178 -0
- package/lib/types/payloads/monetization.js +88 -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 +699 -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 +216 -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 +103 -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 +808 -0
- package/lib/types/utils/index.js +810 -0
- package/lib/websocket/SharedTypes.d.ts +12 -5
- package/lib/websocket/SharedTypes.js +1 -1
- package/lib/websocket/constants/index.d.ts +3 -3
- package/lib/websocket/constants/index.js +11 -1
- package/lib/websocket/discord/basesocket.d.ts +7 -7
- package/lib/websocket/discord/basesocket.js +34 -22
- 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 +83 -57
- package/lib/websocket/discord/sharder.d.ts +6 -5
- package/lib/websocket/discord/sharder.js +70 -11
- package/lib/websocket/discord/shared.d.ts +34 -6
- package/lib/websocket/discord/socket/custom.d.ts +52 -0
- package/lib/websocket/discord/socket/custom.js +300 -0
- package/lib/websocket/discord/worker.d.ts +6 -10
- package/lib/websocket/discord/workermanager.d.ts +10 -16
- package/lib/websocket/discord/workermanager.js +63 -50
- 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 +70 -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 -13
- package/lib/client/onmessagecreate.js +0 -410
- 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, APISubscription, GatewayEntitlementCreateDispatchData } 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,10 +76,12 @@ 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;
|
|
82
83
|
[GatewayDispatchEvents.InteractionCreate]: GatewayInteractionCreateDispatchData;
|
|
84
|
+
[GatewayDispatchEvents.EntitlementCreate]: GatewayEntitlementCreateDispatchData;
|
|
83
85
|
}
|
|
84
86
|
export type StageSameEvents = RestToKeys<[
|
|
85
87
|
APIStageInstance,
|
|
@@ -122,11 +124,16 @@ export type AutoModetaractionRuleEvents = RestToKeys<[
|
|
|
122
124
|
]>;
|
|
123
125
|
export type EntitlementEvents = RestToKeys<[
|
|
124
126
|
APIEntitlement,
|
|
125
|
-
GatewayDispatchEvents.EntitlementCreate,
|
|
126
127
|
GatewayDispatchEvents.EntitlementDelete,
|
|
127
128
|
GatewayDispatchEvents.EntitlementUpdate
|
|
128
129
|
]>;
|
|
129
|
-
export type
|
|
130
|
+
export type SubscriptionEvents = RestToKeys<[
|
|
131
|
+
APISubscription,
|
|
132
|
+
GatewayDispatchEvents.SubscriptionCreate,
|
|
133
|
+
GatewayDispatchEvents.SubscriptionDelete,
|
|
134
|
+
GatewayDispatchEvents.SubscriptionUpdate
|
|
135
|
+
]>;
|
|
136
|
+
export type NormalizeEvents = Events & AutoModetaractionRuleEvents & ChannelSameEvents & GuildScheduledSameEvents & GuildScheduledUserSameEvents & IntegrationSameEvents & EntitlementEvents & PollVoteSameEvents & StageSameEvents & SubscriptionEvents & {
|
|
130
137
|
RAW: GatewayDispatchEvents;
|
|
131
138
|
};
|
|
132
139
|
export type GatewayEvents = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DeepPartial } from '../../common';
|
|
2
2
|
import type { ShardManagerOptions, WorkerManagerOptions } from '../discord';
|
|
3
3
|
declare const COMPRESS = false;
|
|
4
4
|
declare const properties: {
|
|
@@ -6,8 +6,8 @@ declare const properties: {
|
|
|
6
6
|
browser: string;
|
|
7
7
|
device: string;
|
|
8
8
|
};
|
|
9
|
-
declare const ShardManagerDefaults:
|
|
10
|
-
declare const WorkerManagerDefaults:
|
|
9
|
+
declare const ShardManagerDefaults: DeepPartial<ShardManagerOptions>;
|
|
10
|
+
declare const WorkerManagerDefaults: DeepPartial<WorkerManagerOptions>;
|
|
11
11
|
export interface IdentifyProperties {
|
|
12
12
|
/**
|
|
13
13
|
* Operating system the shard runs on.
|
|
@@ -20,11 +20,21 @@ const ShardManagerDefaults = {
|
|
|
20
20
|
handlePayload: (shardId, packet) => {
|
|
21
21
|
console.info(`Packet ${packet.t} on shard ${shardId}`);
|
|
22
22
|
},
|
|
23
|
+
resharding: {
|
|
24
|
+
interval: 8 * 60 * 60 * 1e3, // 8h
|
|
25
|
+
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
|
exports.ShardManagerDefaults = ShardManagerDefaults;
|
|
25
35
|
const WorkerManagerDefaults = {
|
|
26
36
|
...ShardManagerDefaults,
|
|
27
|
-
shardsPerWorker:
|
|
37
|
+
shardsPerWorker: 16,
|
|
28
38
|
handlePayload: (_shardId, _workerId, _packet) => { },
|
|
29
39
|
};
|
|
30
40
|
exports.WorkerManagerDefaults = WorkerManagerDefaults;
|
|
@@ -1,13 +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
|
-
ping(): Promise<number>;
|
|
11
|
+
close(...args: Parameters<SeyfertWebSocket['close']>): void;
|
|
12
12
|
get readyState(): number;
|
|
13
13
|
}
|
|
@@ -1,15 +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
4
|
const node_crypto_1 = require("node:crypto");
|
|
8
|
-
const
|
|
5
|
+
const custom_1 = require("./socket/custom");
|
|
9
6
|
class BaseSocket {
|
|
10
7
|
internal;
|
|
8
|
+
ping;
|
|
11
9
|
constructor(kind, url) {
|
|
12
|
-
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
|
+
}
|
|
13
42
|
}
|
|
14
43
|
set onopen(callback) {
|
|
15
44
|
this.internal.onopen = callback;
|
|
@@ -27,25 +56,8 @@ class BaseSocket {
|
|
|
27
56
|
return this.internal.send(data);
|
|
28
57
|
}
|
|
29
58
|
close(...args) {
|
|
30
|
-
// @ts-expect-error
|
|
31
59
|
return this.internal.close(...args);
|
|
32
60
|
}
|
|
33
|
-
async ping() {
|
|
34
|
-
if (!('ping' in this.internal))
|
|
35
|
-
throw new Error('Unexpected: Method ping not implemented');
|
|
36
|
-
return new Promise(res => {
|
|
37
|
-
const nonce = (0, node_crypto_1.randomUUID)();
|
|
38
|
-
const start = performance.now();
|
|
39
|
-
const listener = (data) => {
|
|
40
|
-
if (data.toString() !== nonce)
|
|
41
|
-
return;
|
|
42
|
-
this.internal.removeListener('pong', listener);
|
|
43
|
-
res(performance.now() - start);
|
|
44
|
-
};
|
|
45
|
-
this.internal.on('pong', listener);
|
|
46
|
-
this.internal.ping(nonce);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
61
|
get readyState() {
|
|
50
62
|
return this.internal.readyState;
|
|
51
63
|
}
|
|
@@ -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 { Logger, type MakeRequired } 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,7 @@ export interface ShardHeart {
|
|
|
16
13
|
}
|
|
17
14
|
export declare class Shard {
|
|
18
15
|
id: number;
|
|
19
|
-
|
|
16
|
+
logger: Logger;
|
|
20
17
|
debugger?: Logger;
|
|
21
18
|
data: Partial<ShardData> | ShardData;
|
|
22
19
|
websocket: BaseSocket | null;
|
|
@@ -24,6 +21,7 @@ export declare class Shard {
|
|
|
24
21
|
heart: ShardHeart;
|
|
25
22
|
bucket: DynamicBucket;
|
|
26
23
|
offlineSendQueue: ((_?: unknown) => void)[];
|
|
24
|
+
options: MakeRequired<ShardOptions, 'properties' | 'ratelimitOptions'>;
|
|
27
25
|
constructor(id: number, options: ShardOptions);
|
|
28
26
|
get latency(): number;
|
|
29
27
|
get isOpen(): boolean;
|
|
@@ -40,9 +38,12 @@ export declare class Shard {
|
|
|
40
38
|
disconnect(): Promise<void>;
|
|
41
39
|
reconnect(): Promise<void>;
|
|
42
40
|
onpacket(packet: GatewayReceivePayload): Promise<void>;
|
|
43
|
-
protected handleClosed(close:
|
|
41
|
+
protected handleClosed(close: {
|
|
42
|
+
code: number;
|
|
43
|
+
reason: string;
|
|
44
|
+
}): Promise<void>;
|
|
44
45
|
close(code: number, reason: string): Promise<void>;
|
|
45
|
-
protected handleMessage(
|
|
46
|
+
protected handleMessage(data: string | Buffer): Promise<void> | undefined;
|
|
46
47
|
checkOffline(force: boolean): Promise<unknown>;
|
|
47
48
|
calculateSafeRequests(): number;
|
|
48
49
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
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
|
-
|
|
14
|
+
logger;
|
|
15
15
|
debugger;
|
|
16
16
|
data = {
|
|
17
|
-
|
|
17
|
+
resume_seq: null,
|
|
18
18
|
};
|
|
19
19
|
websocket = null;
|
|
20
20
|
connectTimeout = new timeout_1.ConnectTimeout();
|
|
@@ -24,13 +24,20 @@ class Shard {
|
|
|
24
24
|
};
|
|
25
25
|
bucket;
|
|
26
26
|
offlineSendQueue = [];
|
|
27
|
+
options;
|
|
27
28
|
constructor(id, options) {
|
|
28
29
|
this.id = id;
|
|
29
|
-
this.options = options
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
this.options = (0, common_1.MergeOptions)(options, {
|
|
31
|
+
properties: constants_1.properties,
|
|
32
|
+
ratelimitOptions: {
|
|
33
|
+
rateLimitResetInterval: 60_000,
|
|
34
|
+
maxRequestsPerRateLimitTick: 120,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
this.logger = new common_1.Logger({
|
|
38
|
+
name: `[Shard #${id}]`,
|
|
39
|
+
logLevel: common_1.LogLevels.Info,
|
|
40
|
+
});
|
|
34
41
|
if (options.debugger)
|
|
35
42
|
this.debugger = options.debugger;
|
|
36
43
|
const safe = this.calculateSafeRequests();
|
|
@@ -42,7 +49,7 @@ class Shard {
|
|
|
42
49
|
: Number.POSITIVE_INFINITY;
|
|
43
50
|
}
|
|
44
51
|
get isOpen() {
|
|
45
|
-
return this.websocket?.readyState ===
|
|
52
|
+
return this.websocket?.readyState === 1 /*WebSocket.open*/;
|
|
46
53
|
}
|
|
47
54
|
get gatewayURL() {
|
|
48
55
|
return this.options.info.url;
|
|
@@ -58,27 +65,31 @@ class Shard {
|
|
|
58
65
|
ping() {
|
|
59
66
|
if (!this.websocket)
|
|
60
67
|
return Promise.resolve(Number.POSITIVE_INFINITY);
|
|
68
|
+
//@ts-expect-error
|
|
61
69
|
return this.websocket.ping();
|
|
62
70
|
}
|
|
63
71
|
async connect() {
|
|
64
72
|
await this.connectTimeout.wait();
|
|
65
73
|
if (this.isOpen) {
|
|
66
|
-
this.debugger?.debug(`[Shard #${this.id}]
|
|
74
|
+
this.debugger?.debug(`[Shard #${this.id}] Attempted to connect while open`);
|
|
67
75
|
return;
|
|
68
76
|
}
|
|
77
|
+
clearTimeout(this.heart.nodeInterval);
|
|
69
78
|
this.debugger?.debug(`[Shard #${this.id}] Connecting to ${this.currentGatewayURL}`);
|
|
70
79
|
// @ts-expect-error @types/bun cause erros in compile
|
|
71
80
|
// biome-ignore lint/correctness/noUndeclaredVariables: /\ bun lol
|
|
72
81
|
this.websocket = new basesocket_1.BaseSocket(typeof Bun === 'undefined' ? 'ws' : 'bun', this.currentGatewayURL);
|
|
73
|
-
this.websocket.onmessage = (
|
|
82
|
+
this.websocket.onmessage = ({ data }) => {
|
|
83
|
+
this.handleMessage(data);
|
|
84
|
+
};
|
|
74
85
|
this.websocket.onclose = (event) => this.handleClosed(event);
|
|
75
|
-
this.websocket.onerror = (event) => this.
|
|
86
|
+
this.websocket.onerror = (event) => this.logger.error(event);
|
|
76
87
|
this.websocket.onopen = () => {
|
|
77
88
|
this.heart.ack = true;
|
|
78
89
|
};
|
|
79
90
|
}
|
|
80
91
|
async send(force, message) {
|
|
81
|
-
this.debugger?.info(`[Shard #${this.id}] Sending: ${
|
|
92
|
+
this.debugger?.info(`[Shard #${this.id}] Sending: ${types_1.GatewayOpcodes[message.op]} ${JSON.stringify(message.d, (_, value) => {
|
|
82
93
|
if (typeof value === 'string')
|
|
83
94
|
return value.replaceAll(this.options.token, v => {
|
|
84
95
|
const split = v.split('.');
|
|
@@ -93,11 +104,11 @@ class Shard {
|
|
|
93
104
|
}
|
|
94
105
|
async identify() {
|
|
95
106
|
await this.send(true, {
|
|
96
|
-
op:
|
|
107
|
+
op: types_1.GatewayOpcodes.Identify,
|
|
97
108
|
d: {
|
|
98
109
|
token: `Bot ${this.options.token}`,
|
|
99
110
|
compress: this.options.compress,
|
|
100
|
-
properties: this.options.properties
|
|
111
|
+
properties: this.options.properties,
|
|
101
112
|
shard: [this.id, this.options.info.shards],
|
|
102
113
|
intents: this.options.intents,
|
|
103
114
|
presence: this.options.presence,
|
|
@@ -105,13 +116,13 @@ class Shard {
|
|
|
105
116
|
});
|
|
106
117
|
}
|
|
107
118
|
get resumable() {
|
|
108
|
-
return !!(this.data.resume_gateway_url && this.data.session_id && this.data.
|
|
119
|
+
return !!(this.data.resume_gateway_url && this.data.session_id && this.data.resume_seq !== null);
|
|
109
120
|
}
|
|
110
121
|
async resume() {
|
|
111
122
|
await this.send(true, {
|
|
112
|
-
op:
|
|
123
|
+
op: types_1.GatewayOpcodes.Resume,
|
|
113
124
|
d: {
|
|
114
|
-
seq: this.data.
|
|
125
|
+
seq: this.data.resume_seq,
|
|
115
126
|
session_id: this.data.session_id,
|
|
116
127
|
token: `Bot ${this.options.token}`,
|
|
117
128
|
},
|
|
@@ -128,8 +139,8 @@ class Shard {
|
|
|
128
139
|
}
|
|
129
140
|
this.heart.lastBeat = Date.now();
|
|
130
141
|
this.websocket.send(JSON.stringify({
|
|
131
|
-
op:
|
|
132
|
-
d: this.data.
|
|
142
|
+
op: types_1.GatewayOpcodes.Heartbeat,
|
|
143
|
+
d: this.data.resume_seq ?? null,
|
|
133
144
|
}));
|
|
134
145
|
}
|
|
135
146
|
async disconnect() {
|
|
@@ -143,11 +154,11 @@ class Shard {
|
|
|
143
154
|
}
|
|
144
155
|
async onpacket(packet) {
|
|
145
156
|
if (packet.s !== null) {
|
|
146
|
-
this.data.
|
|
157
|
+
this.data.resume_seq = packet.s;
|
|
147
158
|
}
|
|
148
|
-
this.debugger?.debug(`[Shard #${this.id}]`, packet.t ? packet.t :
|
|
159
|
+
this.debugger?.debug(`[Shard #${this.id}]`, packet.t ? packet.t : types_1.GatewayOpcodes[packet.op], this.data.resume_seq);
|
|
149
160
|
switch (packet.op) {
|
|
150
|
-
case
|
|
161
|
+
case types_1.GatewayOpcodes.Hello:
|
|
151
162
|
{
|
|
152
163
|
clearInterval(this.heart.nodeInterval);
|
|
153
164
|
this.heart.interval = packet.d.heartbeat_interval;
|
|
@@ -159,37 +170,37 @@ class Shard {
|
|
|
159
170
|
await this.identify();
|
|
160
171
|
}
|
|
161
172
|
break;
|
|
162
|
-
case
|
|
173
|
+
case types_1.GatewayOpcodes.HeartbeatAck:
|
|
163
174
|
this.heart.ack = true;
|
|
164
175
|
this.heart.lastAck = Date.now();
|
|
165
176
|
break;
|
|
166
|
-
case
|
|
177
|
+
case types_1.GatewayOpcodes.Heartbeat:
|
|
167
178
|
this.heartbeat(true);
|
|
168
179
|
break;
|
|
169
|
-
case
|
|
180
|
+
case types_1.GatewayOpcodes.Reconnect:
|
|
170
181
|
await this.reconnect();
|
|
171
182
|
break;
|
|
172
|
-
case
|
|
183
|
+
case types_1.GatewayOpcodes.InvalidSession:
|
|
173
184
|
if (packet.d) {
|
|
174
185
|
if (!this.resumable) {
|
|
175
|
-
return this.
|
|
186
|
+
return this.logger.fatal('This is a completely unexpected error message.');
|
|
176
187
|
}
|
|
177
188
|
await this.resume();
|
|
178
189
|
}
|
|
179
190
|
else {
|
|
180
|
-
this.data.
|
|
191
|
+
this.data.resume_seq = 0;
|
|
181
192
|
this.data.session_id = undefined;
|
|
182
193
|
await this.identify();
|
|
183
194
|
}
|
|
184
195
|
break;
|
|
185
|
-
case
|
|
196
|
+
case types_1.GatewayOpcodes.Dispatch:
|
|
186
197
|
{
|
|
187
198
|
switch (packet.t) {
|
|
188
|
-
case
|
|
199
|
+
case types_1.GatewayDispatchEvents.Resumed:
|
|
189
200
|
this.offlineSendQueue.map((resolve) => resolve());
|
|
190
201
|
this.options.handlePayload(this.id, packet);
|
|
191
202
|
break;
|
|
192
|
-
case
|
|
203
|
+
case types_1.GatewayDispatchEvents.Ready: {
|
|
193
204
|
this.data.resume_gateway_url = packet.d.resume_gateway_url;
|
|
194
205
|
this.data.session_id = packet.d.session_id;
|
|
195
206
|
this.offlineSendQueue.map((resolve) => resolve());
|
|
@@ -206,51 +217,66 @@ class Shard {
|
|
|
206
217
|
}
|
|
207
218
|
async handleClosed(close) {
|
|
208
219
|
clearInterval(this.heart.nodeInterval);
|
|
209
|
-
this.
|
|
220
|
+
this.logger.warn(`${shared_1.ShardSocketCloseCodes[close.code] ?? types_1.GatewayCloseCodes[close.code] ?? close.code} (${close.code})`, close.reason);
|
|
210
221
|
switch (close.code) {
|
|
211
222
|
case shared_1.ShardSocketCloseCodes.Shutdown:
|
|
223
|
+
//Force disconnect, ignore
|
|
212
224
|
break;
|
|
213
225
|
case 1000:
|
|
226
|
+
case types_1.GatewayCloseCodes.UnknownOpcode:
|
|
227
|
+
case types_1.GatewayCloseCodes.InvalidSeq:
|
|
228
|
+
case types_1.GatewayCloseCodes.SessionTimedOut:
|
|
229
|
+
this.data.resume_seq = 0;
|
|
230
|
+
this.data.session_id = undefined;
|
|
231
|
+
this.data.resume_gateway_url = undefined;
|
|
232
|
+
await this.reconnect();
|
|
233
|
+
break;
|
|
214
234
|
case 1001:
|
|
215
235
|
case 1006:
|
|
216
236
|
case shared_1.ShardSocketCloseCodes.ZombiedConnection:
|
|
217
|
-
case
|
|
218
|
-
case
|
|
219
|
-
case
|
|
220
|
-
case
|
|
221
|
-
case
|
|
222
|
-
|
|
223
|
-
case v10_1.GatewayCloseCodes.RateLimited:
|
|
224
|
-
case v10_1.GatewayCloseCodes.SessionTimedOut:
|
|
225
|
-
this.debugger?.info(`[Shard #${this.id}] Trying to reconnect`);
|
|
237
|
+
case types_1.GatewayCloseCodes.UnknownError:
|
|
238
|
+
case types_1.GatewayCloseCodes.DecodeError:
|
|
239
|
+
case types_1.GatewayCloseCodes.NotAuthenticated:
|
|
240
|
+
case types_1.GatewayCloseCodes.AlreadyAuthenticated:
|
|
241
|
+
case types_1.GatewayCloseCodes.RateLimited:
|
|
242
|
+
this.logger.info('Trying to reconnect');
|
|
226
243
|
await this.reconnect();
|
|
227
244
|
break;
|
|
228
|
-
case
|
|
229
|
-
case
|
|
230
|
-
case
|
|
231
|
-
case
|
|
232
|
-
case
|
|
233
|
-
case
|
|
234
|
-
this.
|
|
245
|
+
case types_1.GatewayCloseCodes.AuthenticationFailed:
|
|
246
|
+
case types_1.GatewayCloseCodes.DisallowedIntents:
|
|
247
|
+
case types_1.GatewayCloseCodes.InvalidAPIVersion:
|
|
248
|
+
case types_1.GatewayCloseCodes.InvalidIntents:
|
|
249
|
+
case types_1.GatewayCloseCodes.InvalidShard:
|
|
250
|
+
case types_1.GatewayCloseCodes.ShardingRequired:
|
|
251
|
+
this.logger.fatal('Cannot reconnect');
|
|
235
252
|
break;
|
|
236
253
|
default:
|
|
237
|
-
this.
|
|
254
|
+
this.logger.warn('Unknown close code, trying to reconnect anyways');
|
|
238
255
|
await this.reconnect();
|
|
239
256
|
break;
|
|
240
257
|
}
|
|
241
258
|
}
|
|
242
259
|
async close(code, reason) {
|
|
243
|
-
|
|
260
|
+
clearInterval(this.heart.nodeInterval);
|
|
261
|
+
if (!this.isOpen) {
|
|
244
262
|
return this.debugger?.warn(`[Shard #${this.id}] Is not open`);
|
|
245
263
|
}
|
|
246
|
-
this.debugger?.
|
|
264
|
+
this.debugger?.debug(`[Shard #${this.id}] Called close`);
|
|
247
265
|
this.websocket?.close(code, reason);
|
|
248
266
|
}
|
|
249
|
-
handleMessage(
|
|
250
|
-
|
|
251
|
-
|
|
267
|
+
handleMessage(data) {
|
|
268
|
+
let packet;
|
|
269
|
+
try {
|
|
270
|
+
if (data instanceof Buffer) {
|
|
271
|
+
data = (0, node_zlib_1.inflateSync)(data);
|
|
272
|
+
}
|
|
273
|
+
packet = JSON.parse(data);
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
this.logger.error(e);
|
|
277
|
+
return;
|
|
252
278
|
}
|
|
253
|
-
return this.onpacket(
|
|
279
|
+
return this.onpacket(packet);
|
|
254
280
|
}
|
|
255
281
|
checkOffline(force) {
|
|
256
282
|
if (!this.isOpen) {
|
|
@@ -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
|
}
|