@erinjs/core 1.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/core/.changeset/README.md +8 -0
- package/core/.changeset/community-bootstrap-release.md +17 -0
- package/core/.changeset/config.json +11 -0
- package/core/.changeset/no-changelog.js +16 -0
- package/core/.changeset/pre.json +17 -0
- package/core/.editorconfig +13 -0
- package/core/.gitattributes +2 -0
- package/core/.github/CODE_OF_CONDUCT.md +23 -0
- package/core/.github/FUNDING.yml +7 -0
- package/core/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
- package/core/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- package/core/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- package/core/.github/dependabot.yml +16 -0
- package/core/.github/workflows/autoapp.yml +16 -0
- package/core/.github/workflows/ci.yml +187 -0
- package/core/.github/workflows/codeql.yml +30 -0
- package/core/.github/workflows/deploy-docs.yml +54 -0
- package/core/.github/workflows/publish.yml +43 -0
- package/core/.lintstagedrc.json +4 -0
- package/core/.nvmrc +1 -0
- package/core/.prettierignore +8 -0
- package/core/.prettierrc +11 -0
- package/core/CONTRIBUTING.md +70 -0
- package/core/LICENSE +203 -0
- package/core/README.md +61 -0
- package/core/SECURITY.md +21 -0
- package/core/apps/docs/index.html +28 -0
- package/core/apps/docs/middleware.ts +21 -0
- package/core/apps/docs/package.json +33 -0
- package/core/apps/docs/public/@flux.png +0 -0
- package/core/apps/docs/public/docs/latest/guides.json +1420 -0
- package/core/apps/docs/public/docs/latest/main.json +14981 -0
- package/core/apps/docs/public/docs/latest/rag-index.json +1 -0
- package/core/apps/docs/public/docs/v1.0.5/guides.json +226 -0
- package/core/apps/docs/public/docs/v1.0.5/main.json +7920 -0
- package/core/apps/docs/public/docs/v1.0.6/guides.json +226 -0
- package/core/apps/docs/public/docs/v1.0.6/main.json +7920 -0
- package/core/apps/docs/public/docs/v1.0.7/guides.json +259 -0
- package/core/apps/docs/public/docs/v1.0.7/main.json +8652 -0
- package/core/apps/docs/public/docs/v1.0.8/guides.json +313 -0
- package/core/apps/docs/public/docs/v1.0.8/main.json +9618 -0
- package/core/apps/docs/public/docs/v1.0.9/guides.json +319 -0
- package/core/apps/docs/public/docs/v1.0.9/main.json +10694 -0
- package/core/apps/docs/public/docs/v1.1.0/guides.json +589 -0
- package/core/apps/docs/public/docs/v1.1.0/main.json +12576 -0
- package/core/apps/docs/public/docs/v1.1.2/guides.json +650 -0
- package/core/apps/docs/public/docs/v1.1.2/main.json +13239 -0
- package/core/apps/docs/public/docs/v1.1.3/guides.json +650 -0
- package/core/apps/docs/public/docs/v1.1.3/main.json +13239 -0
- package/core/apps/docs/public/docs/v1.1.4/guides.json +708 -0
- package/core/apps/docs/public/docs/v1.1.4/main.json +13231 -0
- package/core/apps/docs/public/docs/v1.1.5/guides.json +1035 -0
- package/core/apps/docs/public/docs/v1.1.5/main.json +13838 -0
- package/core/apps/docs/public/docs/v1.1.6/guides.json +1041 -0
- package/core/apps/docs/public/docs/v1.1.6/main.json +14313 -0
- package/core/apps/docs/public/docs/v1.1.8/guides.json +1047 -0
- package/core/apps/docs/public/docs/v1.1.8/main.json +14421 -0
- package/core/apps/docs/public/docs/v1.1.9/guides.json +1047 -0
- package/core/apps/docs/public/docs/v1.1.9/main.json +14421 -0
- package/core/apps/docs/public/docs/v1.2.0/guides.json +1212 -0
- package/core/apps/docs/public/docs/v1.2.0/main.json +14663 -0
- package/core/apps/docs/public/docs/v1.2.1/guides.json +1293 -0
- package/core/apps/docs/public/docs/v1.2.1/main.json +14828 -0
- package/core/apps/docs/public/docs/v1.2.2/guides.json +1293 -0
- package/core/apps/docs/public/docs/v1.2.2/main.json +15025 -0
- package/core/apps/docs/public/docs/v1.2.3/guides.json +1420 -0
- package/core/apps/docs/public/docs/v1.2.3/main.json +14954 -0
- package/core/apps/docs/public/docs/v1.2.4/guides.json +1420 -0
- package/core/apps/docs/public/docs/v1.2.4/main.json +14981 -0
- package/core/apps/docs/public/docs/versions.json +24 -0
- package/core/apps/docs/public/flux.png +0 -0
- package/core/apps/docs/public/locales/en.json +50 -0
- package/core/apps/docs/public/locales/guides-en.json +512 -0
- package/core/apps/docs/public/robots.txt +4 -0
- package/core/apps/docs/public/sitemap.xml +33 -0
- package/core/apps/docs/src/App.vue +538 -0
- package/core/apps/docs/src/components/ApiCategorySection.vue +42 -0
- package/core/apps/docs/src/components/ApiDiscordCompat.vue +65 -0
- package/core/apps/docs/src/components/ApiEndpointCard.vue +313 -0
- package/core/apps/docs/src/components/ApiSchemaBlock.vue +131 -0
- package/core/apps/docs/src/components/CodeBlock.vue +177 -0
- package/core/apps/docs/src/components/CommunityCallout.vue +90 -0
- package/core/apps/docs/src/components/ConstructorSection.vue +82 -0
- package/core/apps/docs/src/components/DocDescription.vue +40 -0
- package/core/apps/docs/src/components/FluxerLogo.vue +3 -0
- package/core/apps/docs/src/components/Footer.vue +106 -0
- package/core/apps/docs/src/components/GuideCodeBlock.vue +102 -0
- package/core/apps/docs/src/components/GuideDiscordCompat.vue +77 -0
- package/core/apps/docs/src/components/GuideDiscordCompatCallout.vue +83 -0
- package/core/apps/docs/src/components/GuideTable.vue +77 -0
- package/core/apps/docs/src/components/GuideTip.vue +38 -0
- package/core/apps/docs/src/components/MethodsSection.vue +195 -0
- package/core/apps/docs/src/components/ParamsTable.vue +70 -0
- package/core/apps/docs/src/components/PropertiesSection.vue +143 -0
- package/core/apps/docs/src/components/SearchBar.vue +76 -0
- package/core/apps/docs/src/components/SearchModal.vue +361 -0
- package/core/apps/docs/src/components/SidebarNav.vue +225 -0
- package/core/apps/docs/src/components/SponsorBanner.vue +153 -0
- package/core/apps/docs/src/components/TypeSignature.vue +187 -0
- package/core/apps/docs/src/components/VersionPicker.vue +191 -0
- package/core/apps/docs/src/composables/useSearchIndex.ts +144 -0
- package/core/apps/docs/src/composables/useVersionedPath.ts +20 -0
- package/core/apps/docs/src/data/apiEndpoints.ts +1073 -0
- package/core/apps/docs/src/data/changelog.ts +717 -0
- package/core/apps/docs/src/data/guides.ts +2362 -0
- package/core/apps/docs/src/env.d.ts +7 -0
- package/core/apps/docs/src/locales/guides-en.json +512 -0
- package/core/apps/docs/src/main.ts +27 -0
- package/core/apps/docs/src/pages/ApiReferenceLayout.vue +175 -0
- package/core/apps/docs/src/pages/ApiReferencePage.vue +128 -0
- package/core/apps/docs/src/pages/Changelog.vue +288 -0
- package/core/apps/docs/src/pages/ClassPage.vue +319 -0
- package/core/apps/docs/src/pages/ClassesList.vue +100 -0
- package/core/apps/docs/src/pages/DocsLayout.vue +127 -0
- package/core/apps/docs/src/pages/GuidePage.vue +279 -0
- package/core/apps/docs/src/pages/GuidesIndex.vue +166 -0
- package/core/apps/docs/src/pages/GuidesLayout.vue +245 -0
- package/core/apps/docs/src/pages/Home.vue +125 -0
- package/core/apps/docs/src/pages/NotFound.vue +57 -0
- package/core/apps/docs/src/pages/TypedefPage.vue +230 -0
- package/core/apps/docs/src/pages/TypedefsList.vue +168 -0
- package/core/apps/docs/src/pages/VersionLayout.vue +15 -0
- package/core/apps/docs/src/router.ts +73 -0
- package/core/apps/docs/src/stores/docs.ts +54 -0
- package/core/apps/docs/src/stores/guides.ts +53 -0
- package/core/apps/docs/src/stores/version.ts +67 -0
- package/core/apps/docs/src/styles/main.css +278 -0
- package/core/apps/docs/src/styles/prism.css +95 -0
- package/core/apps/docs/src/types/doc-schema.ts +112 -0
- package/core/apps/docs/tsconfig.json +17 -0
- package/core/apps/docs/tsconfig.node.json +10 -0
- package/core/apps/docs/vite.config.d.ts +2 -0
- package/core/apps/docs/vite.config.js +26 -0
- package/core/apps/docs/vite.config.ts +28 -0
- package/core/apps/docs-vitepress/.vitepress/config.ts +141 -0
- package/core/apps/docs-vitepress/api-data/latest/main.json +15035 -0
- package/core/apps/docs-vitepress/api-data/v1.2.4/main.json +15035 -0
- package/core/apps/docs-vitepress/api-data/versions.json +6 -0
- package/core/apps/docs-vitepress/index.md +15 -0
- package/core/apps/docs-vitepress/package-lock.json +2924 -0
- package/core/apps/docs-vitepress/package.json +20 -0
- package/core/apps/docs-vitepress/public/CNAME +1 -0
- package/core/apps/docs-vitepress/scripts/generate-api.ts +243 -0
- package/core/apps/docs-vitepress/scripts/migrate-guides.ts +129 -0
- package/core/apps/docs-vitepress/tsconfig.json +11 -0
- package/core/apps/docs-vitepress/v/latest/guides/attachments-by-url.md +57 -0
- package/core/apps/docs-vitepress/v/latest/guides/attachments.md +62 -0
- package/core/apps/docs-vitepress/v/latest/guides/basic-bot.md +49 -0
- package/core/apps/docs-vitepress/v/latest/guides/channels.md +180 -0
- package/core/apps/docs-vitepress/v/latest/guides/deprecated-apis.md +58 -0
- package/core/apps/docs-vitepress/v/latest/guides/discord-js-compatibility.md +42 -0
- package/core/apps/docs-vitepress/v/latest/guides/editing-embeds.md +65 -0
- package/core/apps/docs-vitepress/v/latest/guides/embed-media.md +87 -0
- package/core/apps/docs-vitepress/v/latest/guides/embeds.md +166 -0
- package/core/apps/docs-vitepress/v/latest/guides/emojis.md +77 -0
- package/core/apps/docs-vitepress/v/latest/guides/events.md +202 -0
- package/core/apps/docs-vitepress/v/latest/guides/gifs.md +47 -0
- package/core/apps/docs-vitepress/v/latest/guides/installation.md +10 -0
- package/core/apps/docs-vitepress/v/latest/guides/moderation.md +89 -0
- package/core/apps/docs-vitepress/v/latest/guides/permissions.md +130 -0
- package/core/apps/docs-vitepress/v/latest/guides/prefix-commands.md +41 -0
- package/core/apps/docs-vitepress/v/latest/guides/profile-urls.md +58 -0
- package/core/apps/docs-vitepress/v/latest/guides/reactions.md +69 -0
- package/core/apps/docs-vitepress/v/latest/guides/roles.md +130 -0
- package/core/apps/docs-vitepress/v/latest/guides/sending-without-reply.md +172 -0
- package/core/apps/docs-vitepress/v/latest/guides/voice.md +109 -0
- package/core/apps/docs-vitepress/v/latest/guides/wait-for-guilds.md +37 -0
- package/core/apps/docs-vitepress/v/latest/guides/webhook-attachments-embeds.md +73 -0
- package/core/apps/docs-vitepress/v/latest/guides/webhooks.md +131 -0
- package/core/eslint.config.js +80 -0
- package/core/examples/.env.example +22 -0
- package/core/examples/README.md +68 -0
- package/core/examples/first-steps-bot.js +118 -0
- package/core/examples/minimal-bot.js +17 -0
- package/core/examples/moderation-bot.js +209 -0
- package/core/examples/package.json +14 -0
- package/core/examples/ping-bot.js +1146 -0
- package/core/examples/reaction-bot.js +70 -0
- package/core/examples/reaction-roles-bot.js +140 -0
- package/core/examples/webhook-bot.js +239 -0
- package/core/flux.png +0 -0
- package/core/package.json +78 -0
- package/core/packages/builders/package.json +51 -0
- package/core/packages/builders/src/index.ts +13 -0
- package/core/packages/builders/src/messages/AttachmentBuilder.test.ts +79 -0
- package/core/packages/builders/src/messages/AttachmentBuilder.ts +69 -0
- package/core/packages/builders/src/messages/EmbedBuilder.test.ts +266 -0
- package/core/packages/builders/src/messages/EmbedBuilder.ts +239 -0
- package/core/packages/builders/src/messages/MessagePayload.test.ts +118 -0
- package/core/packages/builders/src/messages/MessagePayload.ts +122 -0
- package/core/packages/builders/tsconfig.json +9 -0
- package/core/packages/builders/tsup.config.ts +9 -0
- package/core/packages/builders/vitest.config.ts +9 -0
- package/core/packages/collection/package.json +47 -0
- package/core/packages/collection/src/Collection.test.ts +232 -0
- package/core/packages/collection/src/Collection.ts +196 -0
- package/core/packages/collection/src/index.ts +1 -0
- package/core/packages/collection/tsconfig.json +9 -0
- package/core/packages/collection/tsup.config.ts +9 -0
- package/core/packages/collection/vitest.config.ts +9 -0
- package/core/packages/docgen/package.json +26 -0
- package/core/packages/docgen/src/extract.ts +262 -0
- package/core/packages/docgen/src/formatType.ts +24 -0
- package/core/packages/docgen/src/index.ts +103 -0
- package/core/packages/docgen/src/schema.ts +100 -0
- package/core/packages/docgen/src/visitor.ts +147 -0
- package/core/packages/docgen/tsconfig.json +9 -0
- package/core/packages/docgen/tsup.config.ts +9 -0
- package/core/packages/fluxer-core/README.md +26 -0
- package/core/packages/fluxer-core/package.json +60 -0
- package/core/packages/fluxer-core/src/client/ChannelManager.ts +143 -0
- package/core/packages/fluxer-core/src/client/Client.gateway.test.ts +84 -0
- package/core/packages/fluxer-core/src/client/Client.resolveEmoji.test.ts +45 -0
- package/core/packages/fluxer-core/src/client/Client.ts +558 -0
- package/core/packages/fluxer-core/src/client/ClientUser.ts +40 -0
- package/core/packages/fluxer-core/src/client/EventHandlerRegistry.ts +469 -0
- package/core/packages/fluxer-core/src/client/GuildManager.ts +79 -0
- package/core/packages/fluxer-core/src/client/GuildMemberManager.ts +91 -0
- package/core/packages/fluxer-core/src/client/MessageManager.ts +58 -0
- package/core/packages/fluxer-core/src/client/UsersManager.ts +122 -0
- package/core/packages/fluxer-core/src/errors/ErrorCodes.test.ts +19 -0
- package/core/packages/fluxer-core/src/errors/ErrorCodes.ts +12 -0
- package/core/packages/fluxer-core/src/errors/FluxerError.test.ts +32 -0
- package/core/packages/fluxer-core/src/errors/FluxerError.ts +15 -0
- package/core/packages/fluxer-core/src/index.ts +85 -0
- package/core/packages/fluxer-core/src/structures/Base.ts +7 -0
- package/core/packages/fluxer-core/src/structures/Channel.ts +508 -0
- package/core/packages/fluxer-core/src/structures/Guild.test.ts +189 -0
- package/core/packages/fluxer-core/src/structures/Guild.ts +734 -0
- package/core/packages/fluxer-core/src/structures/GuildBan.ts +35 -0
- package/core/packages/fluxer-core/src/structures/GuildEmoji.ts +57 -0
- package/core/packages/fluxer-core/src/structures/GuildMember.test.ts +203 -0
- package/core/packages/fluxer-core/src/structures/GuildMember.ts +213 -0
- package/core/packages/fluxer-core/src/structures/GuildMemberRoleManager.ts +121 -0
- package/core/packages/fluxer-core/src/structures/GuildSticker.ts +56 -0
- package/core/packages/fluxer-core/src/structures/Invite.test.ts +103 -0
- package/core/packages/fluxer-core/src/structures/Invite.ts +121 -0
- package/core/packages/fluxer-core/src/structures/Message.test.ts +109 -0
- package/core/packages/fluxer-core/src/structures/Message.ts +397 -0
- package/core/packages/fluxer-core/src/structures/MessageReaction.ts +72 -0
- package/core/packages/fluxer-core/src/structures/PartialMessage.ts +12 -0
- package/core/packages/fluxer-core/src/structures/Role.test.ts +77 -0
- package/core/packages/fluxer-core/src/structures/Role.ts +112 -0
- package/core/packages/fluxer-core/src/structures/User.test.ts +110 -0
- package/core/packages/fluxer-core/src/structures/User.ts +109 -0
- package/core/packages/fluxer-core/src/structures/Webhook.test.ts +109 -0
- package/core/packages/fluxer-core/src/structures/Webhook.ts +258 -0
- package/core/packages/fluxer-core/src/util/Constants.test.ts +16 -0
- package/core/packages/fluxer-core/src/util/Constants.ts +7 -0
- package/core/packages/fluxer-core/src/util/Events.ts +46 -0
- package/core/packages/fluxer-core/src/util/MessageCollector.ts +87 -0
- package/core/packages/fluxer-core/src/util/Options.ts +33 -0
- package/core/packages/fluxer-core/src/util/ReactionCollector.ts +116 -0
- package/core/packages/fluxer-core/src/util/cdn.test.ts +108 -0
- package/core/packages/fluxer-core/src/util/cdn.ts +130 -0
- package/core/packages/fluxer-core/src/util/guildUtils.ts +33 -0
- package/core/packages/fluxer-core/src/util/messageUtils.test.ts +74 -0
- package/core/packages/fluxer-core/src/util/messageUtils.ts +119 -0
- package/core/packages/fluxer-core/src/util/permissions.test.ts +95 -0
- package/core/packages/fluxer-core/src/util/permissions.ts +43 -0
- package/core/packages/fluxer-core/tsconfig.json +9 -0
- package/core/packages/fluxer-core/tsup.config.ts +9 -0
- package/core/packages/fluxer-core/vitest.config.ts +9 -0
- package/core/packages/rest/package.json +52 -0
- package/core/packages/rest/src/REST.test.ts +64 -0
- package/core/packages/rest/src/REST.ts +90 -0
- package/core/packages/rest/src/RateLimitManager.test.ts +71 -0
- package/core/packages/rest/src/RateLimitManager.ts +60 -0
- package/core/packages/rest/src/RequestManager.test.ts +87 -0
- package/core/packages/rest/src/RequestManager.ts +172 -0
- package/core/packages/rest/src/errors/FluxerAPIError.test.ts +57 -0
- package/core/packages/rest/src/errors/FluxerAPIError.ts +21 -0
- package/core/packages/rest/src/errors/HTTPError.test.ts +55 -0
- package/core/packages/rest/src/errors/HTTPError.ts +25 -0
- package/core/packages/rest/src/errors/RateLimitError.test.ts +41 -0
- package/core/packages/rest/src/errors/RateLimitError.ts +15 -0
- package/core/packages/rest/src/errors/index.ts +3 -0
- package/core/packages/rest/src/index.ts +6 -0
- package/core/packages/rest/src/utils/constants.test.ts +31 -0
- package/core/packages/rest/src/utils/constants.ts +5 -0
- package/core/packages/rest/src/utils/files.test.ts +37 -0
- package/core/packages/rest/src/utils/files.ts +75 -0
- package/core/packages/rest/tsconfig.json +9 -0
- package/core/packages/rest/tsup.config.ts +9 -0
- package/core/packages/rest/vitest.config.ts +9 -0
- package/core/packages/types/package.json +46 -0
- package/core/packages/types/src/api/ban.ts +8 -0
- package/core/packages/types/src/api/channel.ts +65 -0
- package/core/packages/types/src/api/embed.ts +82 -0
- package/core/packages/types/src/api/emoji.ts +12 -0
- package/core/packages/types/src/api/errors.ts +68 -0
- package/core/packages/types/src/api/gateway.ts +14 -0
- package/core/packages/types/src/api/guild.ts +123 -0
- package/core/packages/types/src/api/index.ts +15 -0
- package/core/packages/types/src/api/instance.ts +32 -0
- package/core/packages/types/src/api/interaction.ts +26 -0
- package/core/packages/types/src/api/invite.ts +28 -0
- package/core/packages/types/src/api/message.ts +140 -0
- package/core/packages/types/src/api/role.ts +41 -0
- package/core/packages/types/src/api/sticker.ts +14 -0
- package/core/packages/types/src/api/user.ts +79 -0
- package/core/packages/types/src/api/webhook.ts +41 -0
- package/core/packages/types/src/common/index.ts +1 -0
- package/core/packages/types/src/common/snowflake.test.ts +9 -0
- package/core/packages/types/src/common/snowflake.ts +8 -0
- package/core/packages/types/src/gateway/events.ts +189 -0
- package/core/packages/types/src/gateway/index.ts +3 -0
- package/core/packages/types/src/gateway/opcodes.ts +17 -0
- package/core/packages/types/src/gateway/payloads.ts +481 -0
- package/core/packages/types/src/index.ts +4 -0
- package/core/packages/types/src/rest/index.ts +1 -0
- package/core/packages/types/src/rest/routes.test.ts +169 -0
- package/core/packages/types/src/rest/routes.ts +109 -0
- package/core/packages/types/tsconfig.json +9 -0
- package/core/packages/types/tsup.config.ts +9 -0
- package/core/packages/types/vitest.config.ts +9 -0
- package/core/packages/util/package.json +51 -0
- package/core/packages/util/src/BitField.test.ts +96 -0
- package/core/packages/util/src/BitField.ts +105 -0
- package/core/packages/util/src/MessageFlagsBitField.test.ts +42 -0
- package/core/packages/util/src/MessageFlagsBitField.ts +20 -0
- package/core/packages/util/src/PermissionsBitField.test.ts +79 -0
- package/core/packages/util/src/PermissionsBitField.ts +97 -0
- package/core/packages/util/src/SnowflakeUtil.test.ts +69 -0
- package/core/packages/util/src/SnowflakeUtil.ts +65 -0
- package/core/packages/util/src/UserFlagsBitField.test.ts +39 -0
- package/core/packages/util/src/UserFlagsBitField.ts +48 -0
- package/core/packages/util/src/deprecation.test.ts +44 -0
- package/core/packages/util/src/deprecation.ts +28 -0
- package/core/packages/util/src/emojiShortcodes.generated.ts +5 -0
- package/core/packages/util/src/emojiShortcodes.test.ts +41 -0
- package/core/packages/util/src/emojiShortcodes.ts +22 -0
- package/core/packages/util/src/formatters.test.ts +65 -0
- package/core/packages/util/src/formatters.ts +35 -0
- package/core/packages/util/src/index.ts +34 -0
- package/core/packages/util/src/resolvers.test.ts +198 -0
- package/core/packages/util/src/resolvers.ts +127 -0
- package/core/packages/util/src/tenorUtils.test.ts +75 -0
- package/core/packages/util/src/tenorUtils.ts +86 -0
- package/core/packages/util/tsconfig.json +9 -0
- package/core/packages/util/tsup.config.ts +9 -0
- package/core/packages/util/vitest.config.ts +9 -0
- package/core/packages/voice/README.md +42 -0
- package/core/packages/voice/package.json +67 -0
- package/core/packages/voice/src/LiveKitRtcConnection.receive.test.ts +24 -0
- package/core/packages/voice/src/LiveKitRtcConnection.ts +1767 -0
- package/core/packages/voice/src/VoiceConnection.ts +413 -0
- package/core/packages/voice/src/VoiceManager.receive.test.ts +61 -0
- package/core/packages/voice/src/VoiceManager.test.ts +44 -0
- package/core/packages/voice/src/VoiceManager.ts +503 -0
- package/core/packages/voice/src/exports.test.ts +38 -0
- package/core/packages/voice/src/index.ts +51 -0
- package/core/packages/voice/src/livekit.test.ts +48 -0
- package/core/packages/voice/src/livekit.ts +33 -0
- package/core/packages/voice/src/mp4box.d.ts +32 -0
- package/core/packages/voice/src/opusUtils.test.ts +29 -0
- package/core/packages/voice/src/opusUtils.ts +86 -0
- package/core/packages/voice/src/streamPreviewPlaceholder.test.ts +16 -0
- package/core/packages/voice/src/streamPreviewPlaceholder.ts +8 -0
- package/core/packages/voice/src/ws.d.ts +1 -0
- package/core/packages/voice/tsconfig.json +5 -0
- package/core/packages/voice/tsup.config.ts +10 -0
- package/core/packages/voice/vitest.config.ts +9 -0
- package/core/packages/ws/package.json +52 -0
- package/core/packages/ws/src/WebSocketManager.ts +130 -0
- package/core/packages/ws/src/WebSocketShard.ts +296 -0
- package/core/packages/ws/src/index.ts +12 -0
- package/core/packages/ws/src/utils/constants.test.ts +46 -0
- package/core/packages/ws/src/utils/constants.ts +22 -0
- package/core/packages/ws/src/utils/getWebSocket.ts +55 -0
- package/core/packages/ws/src/ws.d.ts +10 -0
- package/core/packages/ws/tsconfig.json +9 -0
- package/core/packages/ws/tsup.config.ts +9 -0
- package/core/pnpm-lock.yaml +7033 -0
- package/core/pnpm-workspace.yaml +4 -0
- package/core/scripts/generate-ai-rag.ts +240 -0
- package/core/scripts/generate-docs.ts +143 -0
- package/core/scripts/generate-emoji-shortcodes.ts +58 -0
- package/core/scripts/generate-types.ts +6 -0
- package/core/scripts/publish-ordered.js +63 -0
- package/core/scripts/test-cjs-require.mjs +43 -0
- package/core/scripts/test-esm-imports.mjs +42 -0
- package/core/scripts/test-package-exports.mjs +98 -0
- package/core/scripts/test-smoke.mjs +103 -0
- package/core/tsconfig.json +18 -0
- package/core/turbo.json +30 -0
- package/core/vitest.config.ts +17 -0
- package/core/wrangler.jsonc +9 -0
- package/package.json +26 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { Snowflake } from '../common';
|
|
2
|
+
import {
|
|
3
|
+
APIUser,
|
|
4
|
+
APIChannel,
|
|
5
|
+
APIGuild,
|
|
6
|
+
APIMessage,
|
|
7
|
+
APIGuildMember,
|
|
8
|
+
APIInvite,
|
|
9
|
+
APIRole,
|
|
10
|
+
APIEmoji,
|
|
11
|
+
APISticker,
|
|
12
|
+
} from '../api';
|
|
13
|
+
import { APIApplicationCommandInteraction } from '../api';
|
|
14
|
+
import { GatewayOpcodes } from './opcodes.js';
|
|
15
|
+
import { GatewayDispatchEventName } from './events.js';
|
|
16
|
+
|
|
17
|
+
// Outgoing (client -> gateway)
|
|
18
|
+
export interface GatewayIdentifyData {
|
|
19
|
+
token: string;
|
|
20
|
+
intents: number;
|
|
21
|
+
properties: {
|
|
22
|
+
os: string;
|
|
23
|
+
browser: string;
|
|
24
|
+
device: string;
|
|
25
|
+
};
|
|
26
|
+
compress?: boolean;
|
|
27
|
+
large_threshold?: number;
|
|
28
|
+
shard?: [shardId: number, numShards: number];
|
|
29
|
+
presence?: GatewayPresenceUpdateData;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface GatewayResumeData {
|
|
33
|
+
token: string;
|
|
34
|
+
session_id: string;
|
|
35
|
+
seq: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Custom status object (Fluxer uses this root object rather than Discord-style activities array). */
|
|
39
|
+
export interface GatewayCustomStatus {
|
|
40
|
+
text?: string | null;
|
|
41
|
+
emoji_name?: string | null;
|
|
42
|
+
emoji_id?: string | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface GatewayPresenceUpdateData {
|
|
46
|
+
since?: number | null;
|
|
47
|
+
activities?: Array<{ name: string; type: number; url?: string | null }>;
|
|
48
|
+
/** Custom status; set text (and optionally emoji) for bots. Passable on identify and via presence update. */
|
|
49
|
+
custom_status?: GatewayCustomStatus | null;
|
|
50
|
+
status: 'online' | 'idle' | 'dnd' | 'invisible';
|
|
51
|
+
afk?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface GatewayVoiceStateUpdateData {
|
|
55
|
+
guild_id: Snowflake;
|
|
56
|
+
channel_id: Snowflake | null;
|
|
57
|
+
self_mute?: boolean;
|
|
58
|
+
self_deaf?: boolean;
|
|
59
|
+
/** Whether the user has video enabled (e.g. camera). */
|
|
60
|
+
self_video?: boolean;
|
|
61
|
+
/** Whether the user is screen sharing / streaming. */
|
|
62
|
+
self_stream?: boolean;
|
|
63
|
+
/** Connection ID from VoiceServerUpdate; required for updates when already in channel. */
|
|
64
|
+
connection_id?: string | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type GatewaySendPayload =
|
|
68
|
+
| { op: GatewayOpcodes.Identify; d: GatewayIdentifyData }
|
|
69
|
+
| { op: GatewayOpcodes.Resume; d: GatewayResumeData }
|
|
70
|
+
| { op: GatewayOpcodes.Heartbeat; d: number | null }
|
|
71
|
+
| { op: GatewayOpcodes.PresenceUpdate; d: GatewayPresenceUpdateData }
|
|
72
|
+
| { op: GatewayOpcodes.VoiceStateUpdate; d: GatewayVoiceStateUpdateData }
|
|
73
|
+
| {
|
|
74
|
+
op: GatewayOpcodes.RequestGuildMembers;
|
|
75
|
+
d: { guild_id: Snowflake; query?: string; limit: number };
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Incoming (gateway -> client)
|
|
79
|
+
export interface GatewayHelloData {
|
|
80
|
+
heartbeat_interval: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** READY — v, user, guilds, session_id, shard?, application */
|
|
84
|
+
export interface GatewayReadyDispatchData {
|
|
85
|
+
v: number;
|
|
86
|
+
user: APIUser;
|
|
87
|
+
guilds: Array<APIGuild & { unavailable?: boolean }>;
|
|
88
|
+
session_id: string;
|
|
89
|
+
shard?: [number, number];
|
|
90
|
+
application: { id: Snowflake; flags: number };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** MESSAGE_CREATE — full message with author, content, embeds, attachments, member? (guild). */
|
|
94
|
+
export type GatewayMessageCreateDispatchData = APIMessage;
|
|
95
|
+
/** MESSAGE_UPDATE — partial message (edited fields). */
|
|
96
|
+
export type GatewayMessageUpdateDispatchData = APIMessage;
|
|
97
|
+
/** MESSAGE_DELETE — id, channel_id, guild_id?, content?, author_id? (Fluxer may send content/author_id) */
|
|
98
|
+
export interface GatewayMessageDeleteDispatchData {
|
|
99
|
+
id: Snowflake;
|
|
100
|
+
channel_id: Snowflake;
|
|
101
|
+
guild_id?: Snowflake;
|
|
102
|
+
content?: string | null;
|
|
103
|
+
author_id?: Snowflake | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** MESSAGE_DELETE_BULK — ids[], channel_id, guild_id? */
|
|
107
|
+
export interface GatewayMessageDeleteBulkDispatchData {
|
|
108
|
+
ids: Snowflake[];
|
|
109
|
+
channel_id: Snowflake;
|
|
110
|
+
guild_id?: Snowflake;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Emoji data sent with reaction events (id is null for unicode emoji). */
|
|
114
|
+
export interface GatewayReactionEmoji {
|
|
115
|
+
id?: Snowflake;
|
|
116
|
+
name: string;
|
|
117
|
+
animated?: boolean;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** MESSAGE_REACTION_ADD — message_id, channel_id, user_id, guild_id?, emoji */
|
|
121
|
+
export interface GatewayMessageReactionAddDispatchData {
|
|
122
|
+
message_id: Snowflake;
|
|
123
|
+
channel_id: Snowflake;
|
|
124
|
+
user_id: Snowflake;
|
|
125
|
+
guild_id?: Snowflake;
|
|
126
|
+
emoji: GatewayReactionEmoji;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** MESSAGE_REACTION_REMOVE — message_id, channel_id, user_id, guild_id?, emoji */
|
|
130
|
+
export interface GatewayMessageReactionRemoveDispatchData {
|
|
131
|
+
message_id: Snowflake;
|
|
132
|
+
channel_id: Snowflake;
|
|
133
|
+
user_id: Snowflake;
|
|
134
|
+
guild_id?: Snowflake;
|
|
135
|
+
emoji: GatewayReactionEmoji;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** MESSAGE_REACTION_REMOVE_EMOJI — message_id, channel_id, guild_id?, emoji */
|
|
139
|
+
export interface GatewayMessageReactionRemoveEmojiDispatchData {
|
|
140
|
+
message_id: Snowflake;
|
|
141
|
+
channel_id: Snowflake;
|
|
142
|
+
guild_id?: Snowflake;
|
|
143
|
+
emoji: GatewayReactionEmoji;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** MESSAGE_REACTION_REMOVE_ALL — message_id, channel_id, guild_id? */
|
|
147
|
+
export interface GatewayMessageReactionRemoveAllDispatchData {
|
|
148
|
+
message_id: Snowflake;
|
|
149
|
+
channel_id: Snowflake;
|
|
150
|
+
guild_id?: Snowflake;
|
|
151
|
+
}
|
|
152
|
+
/** MESSAGE_ACK — read receipt; message_id, channel_id */
|
|
153
|
+
export interface GatewayMessageAckDispatchData {
|
|
154
|
+
message_id: Snowflake;
|
|
155
|
+
channel_id: Snowflake;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** GUILD_CREATE — full guild with channels, members, roles, unavailable? */
|
|
159
|
+
export type GatewayGuildCreateDispatchData = APIGuild & { unavailable?: boolean };
|
|
160
|
+
/** GUILD_UPDATE — full guild object */
|
|
161
|
+
export type GatewayGuildUpdateDispatchData = APIGuild;
|
|
162
|
+
/** GUILD_DELETE — id, unavailable? (true = temp outage) */
|
|
163
|
+
export interface GatewayGuildDeleteDispatchData {
|
|
164
|
+
id: Snowflake;
|
|
165
|
+
unavailable?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** CHANNEL_CREATE — full channel */
|
|
169
|
+
export type GatewayChannelCreateDispatchData = APIChannel;
|
|
170
|
+
/** CHANNEL_UPDATE — full channel */
|
|
171
|
+
export type GatewayChannelUpdateDispatchData = APIChannel;
|
|
172
|
+
/** CHANNEL_UPDATE_BULK — channels[] */
|
|
173
|
+
export interface GatewayChannelUpdateBulkDispatchData {
|
|
174
|
+
channels: APIChannel[];
|
|
175
|
+
}
|
|
176
|
+
/** CHANNEL_DELETE — full channel */
|
|
177
|
+
export type GatewayChannelDeleteDispatchData = APIChannel;
|
|
178
|
+
/** CHANNEL_RECIPIENT_ADD — channel_id, user (group DM) */
|
|
179
|
+
export interface GatewayChannelRecipientAddDispatchData {
|
|
180
|
+
channel_id: Snowflake;
|
|
181
|
+
user: APIUser;
|
|
182
|
+
}
|
|
183
|
+
/** CHANNEL_RECIPIENT_REMOVE — channel_id, user (group DM) */
|
|
184
|
+
export interface GatewayChannelRecipientRemoveDispatchData {
|
|
185
|
+
channel_id: Snowflake;
|
|
186
|
+
user: APIUser;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** GUILD_MEMBER_ADD — member + guild_id */
|
|
190
|
+
export type GatewayGuildMemberAddDispatchData = APIGuildMember & { guild_id: Snowflake };
|
|
191
|
+
/** GUILD_MEMBER_UPDATE — guild_id, roles, user, nick?, avatar?, joined_at?, ... */
|
|
192
|
+
export interface GatewayGuildMemberUpdateDispatchData {
|
|
193
|
+
guild_id: Snowflake;
|
|
194
|
+
roles: Snowflake[];
|
|
195
|
+
user: APIUser;
|
|
196
|
+
nick?: string | null;
|
|
197
|
+
avatar?: string | null;
|
|
198
|
+
joined_at?: string;
|
|
199
|
+
premium_since?: string | null;
|
|
200
|
+
communication_disabled_until?: string | null;
|
|
201
|
+
}
|
|
202
|
+
/** GUILD_MEMBER_REMOVE — guild_id, user */
|
|
203
|
+
export interface GatewayGuildMemberRemoveDispatchData {
|
|
204
|
+
guild_id: Snowflake;
|
|
205
|
+
user: APIUser;
|
|
206
|
+
}
|
|
207
|
+
/** GUILD_MEMBERS_CHUNK — from request_guild_members; members[], chunk_index, chunk_count */
|
|
208
|
+
export interface GatewayGuildMembersChunkDispatchData {
|
|
209
|
+
guild_id: Snowflake;
|
|
210
|
+
members: Array<APIGuildMember & { guild_id?: Snowflake }>;
|
|
211
|
+
chunk_index: number;
|
|
212
|
+
chunk_count: number;
|
|
213
|
+
presences?: Array<{ user: { id: Snowflake }; status?: string; activities?: unknown[] }>;
|
|
214
|
+
nonce?: string | null;
|
|
215
|
+
}
|
|
216
|
+
/** GUILD_MEMBER_LIST_UPDATE — lazy member list; guild_id, id (list_id), member_count, online_count, groups, ops */
|
|
217
|
+
export interface GatewayGuildMemberListUpdateDispatchData {
|
|
218
|
+
guild_id: Snowflake;
|
|
219
|
+
id: string;
|
|
220
|
+
member_count: number;
|
|
221
|
+
online_count: number;
|
|
222
|
+
groups: Array<{ id: string; count: number }>;
|
|
223
|
+
ops: Array<{
|
|
224
|
+
op: 'SYNC' | 'INVALIDATE';
|
|
225
|
+
range?: [number, number];
|
|
226
|
+
items?: Array<Record<string, unknown>>;
|
|
227
|
+
}>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** GUILD_BAN_ADD — guild_id, user, reason? */
|
|
231
|
+
export interface GatewayGuildBanAddDispatchData {
|
|
232
|
+
guild_id: Snowflake;
|
|
233
|
+
user: APIUser;
|
|
234
|
+
reason?: string | null;
|
|
235
|
+
}
|
|
236
|
+
/** GUILD_BAN_REMOVE — guild_id, user */
|
|
237
|
+
export interface GatewayGuildBanRemoveDispatchData {
|
|
238
|
+
guild_id: Snowflake;
|
|
239
|
+
user: APIUser;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* INVITE_CREATE — invite payload from gateway.
|
|
244
|
+
* The Fluxer Docs indicate this event can, or is an empty payload; some instances may also send partial invite fields.
|
|
245
|
+
*/
|
|
246
|
+
export interface GatewayInviteCreateDispatchData extends Partial<APIInvite> {
|
|
247
|
+
code?: string;
|
|
248
|
+
guild_id?: Snowflake;
|
|
249
|
+
channel_id?: Snowflake;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** INVITE_DELETE — code, channel_id, guild_id? */
|
|
253
|
+
export interface GatewayInviteDeleteDispatchData {
|
|
254
|
+
code: string;
|
|
255
|
+
channel_id: Snowflake;
|
|
256
|
+
guild_id?: Snowflake;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** TYPING_START — channel_id, user_id, timestamp, guild_id?, member? */
|
|
260
|
+
export interface GatewayTypingStartDispatchData {
|
|
261
|
+
channel_id: Snowflake;
|
|
262
|
+
user_id: Snowflake;
|
|
263
|
+
timestamp: number;
|
|
264
|
+
guild_id?: Snowflake;
|
|
265
|
+
member?: APIGuildMember & { guild_id?: Snowflake };
|
|
266
|
+
}
|
|
267
|
+
/** USER_UPDATE — full current user (APIUser) */
|
|
268
|
+
export type GatewayUserUpdateDispatchData = APIUser;
|
|
269
|
+
|
|
270
|
+
/** GUILD_ROLE_CREATE — guild_id, role */
|
|
271
|
+
export interface GatewayGuildRoleCreateDispatchData {
|
|
272
|
+
guild_id: Snowflake;
|
|
273
|
+
role: APIRole;
|
|
274
|
+
}
|
|
275
|
+
/** GUILD_ROLE_UPDATE — guild_id, role */
|
|
276
|
+
export interface GatewayGuildRoleUpdateDispatchData {
|
|
277
|
+
guild_id: Snowflake;
|
|
278
|
+
role: APIRole;
|
|
279
|
+
}
|
|
280
|
+
/** GUILD_ROLE_DELETE — guild_id, role_id */
|
|
281
|
+
export interface GatewayGuildRoleDeleteDispatchData {
|
|
282
|
+
guild_id: Snowflake;
|
|
283
|
+
role_id: Snowflake;
|
|
284
|
+
}
|
|
285
|
+
/** GUILD_ROLE_UPDATE_BULK — guild_id, roles[] */
|
|
286
|
+
export interface GatewayGuildRoleUpdateBulkDispatchData {
|
|
287
|
+
guild_id: Snowflake;
|
|
288
|
+
roles: APIRole[];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** VOICE_STATE_UPDATE — guild_id?, channel_id, user_id, member?, session_id, deaf?, mute?, ... */
|
|
292
|
+
export interface GatewayVoiceStateUpdateDispatchData {
|
|
293
|
+
guild_id?: Snowflake;
|
|
294
|
+
channel_id: Snowflake | null;
|
|
295
|
+
user_id: Snowflake;
|
|
296
|
+
member?: APIGuildMember & { guild_id?: Snowflake };
|
|
297
|
+
session_id: string;
|
|
298
|
+
/** Connection ID for voice session (Fluxer). */
|
|
299
|
+
connection_id?: string | null;
|
|
300
|
+
deaf?: boolean;
|
|
301
|
+
mute?: boolean;
|
|
302
|
+
self_deaf?: boolean;
|
|
303
|
+
self_mute?: boolean;
|
|
304
|
+
self_video?: boolean;
|
|
305
|
+
/** Whether the user is screen sharing / streaming. */
|
|
306
|
+
self_stream?: boolean;
|
|
307
|
+
suppress?: boolean;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** VOICE_SERVER_UPDATE — token, guild_id, endpoint, connection_id? */
|
|
311
|
+
export interface GatewayVoiceServerUpdateDispatchData {
|
|
312
|
+
token: string;
|
|
313
|
+
guild_id: Snowflake;
|
|
314
|
+
endpoint: string | null;
|
|
315
|
+
/** Connection ID for subsequent voice state updates (Fluxer). */
|
|
316
|
+
connection_id?: string | null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** GUILD_EMOJIS_UPDATE — emoji list for a guild changed. */
|
|
320
|
+
export interface GatewayGuildEmojisUpdateDispatchData {
|
|
321
|
+
guild_id: Snowflake;
|
|
322
|
+
emojis: APIEmoji[];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** GUILD_STICKERS_UPDATE — sticker list for a guild changed. */
|
|
326
|
+
export interface GatewayGuildStickersUpdateDispatchData {
|
|
327
|
+
guild_id: Snowflake;
|
|
328
|
+
stickers: APISticker[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** GUILD_INTEGRATIONS_UPDATE — integrations for a guild changed. */
|
|
332
|
+
export interface GatewayGuildIntegrationsUpdateDispatchData {
|
|
333
|
+
guild_id: Snowflake;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** GUILD_SCHEDULED_EVENT_CREATE — a scheduled event was created. */
|
|
337
|
+
export interface GatewayGuildScheduledEventCreateDispatchData {
|
|
338
|
+
guild_id: Snowflake;
|
|
339
|
+
id: Snowflake;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** GUILD_SCHEDULED_EVENT_UPDATE — a scheduled event was updated. */
|
|
343
|
+
export interface GatewayGuildScheduledEventUpdateDispatchData {
|
|
344
|
+
guild_id: Snowflake;
|
|
345
|
+
id: Snowflake;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** GUILD_SCHEDULED_EVENT_DELETE — a scheduled event was deleted. */
|
|
349
|
+
export interface GatewayGuildScheduledEventDeleteDispatchData {
|
|
350
|
+
guild_id: Snowflake;
|
|
351
|
+
id: Snowflake;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** CHANNEL_PINS_UPDATE — pins in a channel changed. */
|
|
355
|
+
export interface GatewayChannelPinsUpdateDispatchData {
|
|
356
|
+
guild_id?: Snowflake;
|
|
357
|
+
channel_id: Snowflake;
|
|
358
|
+
last_pin_timestamp?: string | null;
|
|
359
|
+
}
|
|
360
|
+
/** CHANNEL_PINS_ACK — user acknowledged viewing pinned messages */
|
|
361
|
+
export interface GatewayChannelPinsAckDispatchData {
|
|
362
|
+
channel_id: Snowflake;
|
|
363
|
+
last_pin_timestamp?: string | null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** PRESENCE_UPDATE — user presence (status, activities) changed. */
|
|
367
|
+
export interface GatewayPresenceUpdateDispatchData {
|
|
368
|
+
user: { id: Snowflake };
|
|
369
|
+
guild_id?: Snowflake;
|
|
370
|
+
status?: string;
|
|
371
|
+
activities?: Array<{ name: string; type: number; url?: string | null }>;
|
|
372
|
+
/** Custom status (Fluxer). */
|
|
373
|
+
custom_status?: GatewayCustomStatus | null;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** WEBHOOKS_UPDATE — webhooks in a channel were updated. */
|
|
377
|
+
export interface GatewayWebhooksUpdateDispatchData {
|
|
378
|
+
guild_id: Snowflake;
|
|
379
|
+
channel_id: Snowflake;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// ─── Additional gateway events (session/user-scoped) ─────────────────────────
|
|
383
|
+
|
|
384
|
+
/** RESUMED — connection resumed; typically no payload. */
|
|
385
|
+
export type GatewayResumedDispatchData = undefined;
|
|
386
|
+
|
|
387
|
+
/** SESSIONS_REPLACE — user's active sessions list replaced */
|
|
388
|
+
export interface GatewaySessionsReplaceDispatchData {
|
|
389
|
+
sessions?: Array<Record<string, unknown>>;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** USER_SETTINGS_UPDATE — user settings (theme, locale, etc.) changed */
|
|
393
|
+
export type GatewayUserSettingsUpdateDispatchData = Record<string, unknown>;
|
|
394
|
+
|
|
395
|
+
/** USER_GUILD_SETTINGS_UPDATE — per-guild settings changed */
|
|
396
|
+
export type GatewayUserGuildSettingsUpdateDispatchData = Record<string, unknown>;
|
|
397
|
+
|
|
398
|
+
/** USER_PINNED_DMS_UPDATE — pinned DM order changed */
|
|
399
|
+
export type GatewayUserPinnedDmsUpdateDispatchData = Record<string, unknown>;
|
|
400
|
+
|
|
401
|
+
/** USER_NOTE_UPDATE — note on another user changed */
|
|
402
|
+
export interface GatewayUserNoteUpdateDispatchData {
|
|
403
|
+
id: Snowflake;
|
|
404
|
+
note?: string | null;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** RECENT_MENTION_DELETE — recent mention cleared */
|
|
408
|
+
export type GatewayRecentMentionDeleteDispatchData = Record<string, unknown>;
|
|
409
|
+
|
|
410
|
+
/** SAVED_MESSAGE_CREATE — message saved (bookmarked) */
|
|
411
|
+
export type GatewaySavedMessageCreateDispatchData = APIMessage;
|
|
412
|
+
|
|
413
|
+
/** SAVED_MESSAGE_DELETE — saved message unsaved */
|
|
414
|
+
export interface GatewaySavedMessageDeleteDispatchData {
|
|
415
|
+
id: Snowflake;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/** AUTH_SESSION_CHANGE — login/logout on another client */
|
|
419
|
+
export type GatewayAuthSessionChangeDispatchData = Record<string, unknown>;
|
|
420
|
+
|
|
421
|
+
/** PASSIVE_UPDATES — lazy-loaded entity updates */
|
|
422
|
+
export type GatewayPassiveUpdatesDispatchData = Record<string, unknown>;
|
|
423
|
+
|
|
424
|
+
/** GUILD_SYNC — guild sync state (passive/lazy) */
|
|
425
|
+
export type GatewayGuildSyncDispatchData = Record<string, unknown>;
|
|
426
|
+
|
|
427
|
+
/** RELATIONSHIP_ADD — relationship (friend, block) added */
|
|
428
|
+
export interface GatewayRelationshipAddDispatchData {
|
|
429
|
+
id: Snowflake;
|
|
430
|
+
type: number;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** RELATIONSHIP_UPDATE — relationship updated */
|
|
434
|
+
export interface GatewayRelationshipUpdateDispatchData {
|
|
435
|
+
id: Snowflake;
|
|
436
|
+
type: number;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** RELATIONSHIP_REMOVE — relationship removed */
|
|
440
|
+
export interface GatewayRelationshipRemoveDispatchData {
|
|
441
|
+
id: Snowflake;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** CALL_CREATE — call created */
|
|
445
|
+
export interface GatewayCallCreateDispatchData {
|
|
446
|
+
id: Snowflake;
|
|
447
|
+
channel_id: Snowflake;
|
|
448
|
+
[key: string]: unknown;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** CALL_UPDATE — call updated */
|
|
452
|
+
export interface GatewayCallUpdateDispatchData {
|
|
453
|
+
id: Snowflake;
|
|
454
|
+
channel_id: Snowflake;
|
|
455
|
+
[key: string]: unknown;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** CALL_DELETE — call ended */
|
|
459
|
+
export interface GatewayCallDeleteDispatchData {
|
|
460
|
+
id: Snowflake;
|
|
461
|
+
channel_id: Snowflake;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** FAVORITE_MEME_CREATE — favorite meme/media added */
|
|
465
|
+
export type GatewayFavoriteMemeCreateDispatchData = Record<string, unknown>;
|
|
466
|
+
|
|
467
|
+
/** FAVORITE_MEME_UPDATE — favorite meme/media updated */
|
|
468
|
+
export type GatewayFavoriteMemeUpdateDispatchData = Record<string, unknown>;
|
|
469
|
+
|
|
470
|
+
/** FAVORITE_MEME_DELETE — favorite meme/media removed */
|
|
471
|
+
export type GatewayFavoriteMemeDeleteDispatchData = Record<string, unknown>;
|
|
472
|
+
|
|
473
|
+
/** INTERACTION_CREATE — slash command or component interaction */
|
|
474
|
+
export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction;
|
|
475
|
+
|
|
476
|
+
export interface GatewayReceivePayload<T = unknown> {
|
|
477
|
+
op: GatewayOpcodes;
|
|
478
|
+
d?: T;
|
|
479
|
+
s?: number;
|
|
480
|
+
t?: GatewayDispatchEventName;
|
|
481
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './routes.js';
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { Routes } from './routes.js';
|
|
3
|
+
|
|
4
|
+
describe('Routes', () => {
|
|
5
|
+
describe('channelMessageReaction', () => {
|
|
6
|
+
it('encodes unicode emoji in URL', () => {
|
|
7
|
+
const path = Routes.channelMessageReaction('123', '456', '❤');
|
|
8
|
+
expect(path).toContain(encodeURIComponent('❤'));
|
|
9
|
+
expect(path).toMatch(/reactions\/[^/]+\/?/);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('encodes custom emoji name:id format', () => {
|
|
13
|
+
const path = Routes.channelMessageReaction('123', '456', 'custom:123456789012345678');
|
|
14
|
+
expect(path).toContain(encodeURIComponent('custom:123456789012345678'));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('does not double-encode already encoded input', () => {
|
|
18
|
+
const encoded = encodeURIComponent('❤');
|
|
19
|
+
const path = Routes.channelMessageReaction('123', '456', encoded);
|
|
20
|
+
expect(path).toContain('%25E2%259D%25A4'); // double-encoded
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('channel', () => {
|
|
25
|
+
it('builds channel path', () => {
|
|
26
|
+
expect(Routes.channel('123456789012345678')).toBe('/channels/123456789012345678');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('channelMessage', () => {
|
|
31
|
+
it('builds message path', () => {
|
|
32
|
+
expect(Routes.channelMessage('111', '222')).toBe('/channels/111/messages/222');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('invite', () => {
|
|
37
|
+
it('encodes invite code', () => {
|
|
38
|
+
const path = Routes.invite('abc123');
|
|
39
|
+
expect(path).toBe('/invites/abc123');
|
|
40
|
+
expect(Routes.invite('code+with/special')).toContain(encodeURIComponent('code+with/special'));
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('guild routes', () => {
|
|
45
|
+
it('guild builds path', () => {
|
|
46
|
+
expect(Routes.guild('123456789012345678')).toBe('/guilds/123456789012345678');
|
|
47
|
+
});
|
|
48
|
+
it('guildChannels builds path', () => {
|
|
49
|
+
expect(Routes.guildChannels('123')).toBe('/guilds/123/channels');
|
|
50
|
+
});
|
|
51
|
+
it('guildMember builds path', () => {
|
|
52
|
+
expect(Routes.guildMember('g1', 'u1')).toBe('/guilds/g1/members/u1');
|
|
53
|
+
});
|
|
54
|
+
it('guildMemberRole builds path', () => {
|
|
55
|
+
expect(Routes.guildMemberRole('g1', 'u1', 'r1')).toBe('/guilds/g1/members/u1/roles/r1');
|
|
56
|
+
});
|
|
57
|
+
it('guildBan builds path', () => {
|
|
58
|
+
expect(Routes.guildBan('g1', 'u1')).toBe('/guilds/g1/bans/u1');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('webhook routes', () => {
|
|
63
|
+
it('webhook builds path', () => {
|
|
64
|
+
expect(Routes.webhook('123')).toBe('/webhooks/123');
|
|
65
|
+
});
|
|
66
|
+
it('webhookExecute builds path with token', () => {
|
|
67
|
+
expect(Routes.webhookExecute('wid', 'token123')).toBe('/webhooks/wid/token123');
|
|
68
|
+
});
|
|
69
|
+
it('webhookMessage builds path with token and message id', () => {
|
|
70
|
+
expect(Routes.webhookMessage('wid', 'token123', 'mid')).toBe(
|
|
71
|
+
'/webhooks/wid/token123/messages/mid',
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('application commands', () => {
|
|
77
|
+
it('applicationCommands builds path', () => {
|
|
78
|
+
expect(Routes.applicationCommands('app123')).toBe('/applications/app123/commands');
|
|
79
|
+
});
|
|
80
|
+
it('applicationCommand builds path', () => {
|
|
81
|
+
expect(Routes.applicationCommand('app123', 'cmd456')).toBe(
|
|
82
|
+
'/applications/app123/commands/cmd456',
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
it('interactionCallback builds path', () => {
|
|
86
|
+
const path = Routes.interactionCallback('iid', 'itoken');
|
|
87
|
+
expect(path).toBe('/interactions/iid/itoken/callback');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('user routes', () => {
|
|
92
|
+
it('user builds path', () => {
|
|
93
|
+
expect(Routes.user('123')).toBe('/users/123');
|
|
94
|
+
});
|
|
95
|
+
it('currentUser builds path', () => {
|
|
96
|
+
expect(Routes.currentUser()).toBe('/users/@me');
|
|
97
|
+
});
|
|
98
|
+
it('userProfile without guild', () => {
|
|
99
|
+
expect(Routes.userProfile('uid')).toBe('/users/uid/profile');
|
|
100
|
+
});
|
|
101
|
+
it('userProfile with guild', () => {
|
|
102
|
+
expect(Routes.userProfile('uid', 'gid')).toBe('/users/uid/profile?guild_id=gid');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('gateway and instance', () => {
|
|
107
|
+
it('gatewayBot builds path', () => {
|
|
108
|
+
expect(Routes.gatewayBot()).toBe('/gateway/bot');
|
|
109
|
+
});
|
|
110
|
+
it('instanceDiscovery builds path', () => {
|
|
111
|
+
expect(Routes.instanceDiscovery()).toBe('/.well-known/fluxer');
|
|
112
|
+
});
|
|
113
|
+
it('instance builds path', () => {
|
|
114
|
+
expect(Routes.instance()).toBe('/instance');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('stream preview', () => {
|
|
119
|
+
it('encodes stream key', () => {
|
|
120
|
+
const path = Routes.streamPreview('key+with/special');
|
|
121
|
+
expect(path).toContain('/streams/');
|
|
122
|
+
expect(path).toContain(encodeURIComponent('key+with/special'));
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('channel routes', () => {
|
|
127
|
+
it('channelMessages builds path', () => {
|
|
128
|
+
expect(Routes.channelMessages('c1')).toBe('/channels/c1/messages');
|
|
129
|
+
});
|
|
130
|
+
it('channelBulkDelete builds path', () => {
|
|
131
|
+
expect(Routes.channelBulkDelete('c1')).toBe('/channels/c1/messages/bulk-delete');
|
|
132
|
+
});
|
|
133
|
+
it('channelTyping builds path', () => {
|
|
134
|
+
expect(Routes.channelTyping('c1')).toBe('/channels/c1/typing');
|
|
135
|
+
});
|
|
136
|
+
it('channelPins builds path', () => {
|
|
137
|
+
expect(Routes.channelPins('c1')).toBe('/channels/c1/messages/pins');
|
|
138
|
+
});
|
|
139
|
+
it('channelPinMessage builds path', () => {
|
|
140
|
+
expect(Routes.channelPinMessage('c1', 'm1')).toBe('/channels/c1/pins/m1');
|
|
141
|
+
});
|
|
142
|
+
it('channelPermission builds path', () => {
|
|
143
|
+
expect(Routes.channelPermission('c1', 'o1')).toBe('/channels/c1/permissions/o1');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('oauth2 routes', () => {
|
|
148
|
+
it('oauth2ApplicationBot builds path', () => {
|
|
149
|
+
expect(Routes.oauth2ApplicationBot('app1')).toBe('/oauth2/applications/app1/bot');
|
|
150
|
+
});
|
|
151
|
+
it('oauth2ApplicationBotResetToken builds path', () => {
|
|
152
|
+
expect(Routes.oauth2ApplicationBotResetToken('app1')).toBe(
|
|
153
|
+
'/oauth2/applications/app1/bot/reset-token',
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('user routes extended', () => {
|
|
159
|
+
it('leaveGuild builds path', () => {
|
|
160
|
+
expect(Routes.leaveGuild('g1')).toBe('/users/@me/guilds/g1');
|
|
161
|
+
});
|
|
162
|
+
it('userMeChannels builds path', () => {
|
|
163
|
+
expect(Routes.userMeChannels()).toBe('/users/@me/channels');
|
|
164
|
+
});
|
|
165
|
+
it('currentUserGuilds builds path', () => {
|
|
166
|
+
expect(Routes.currentUserGuilds()).toBe('/users/@me/guilds');
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|