@erinjs/core 1.0.0 → 1.2.4
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/LICENSE → LICENSE} +203 -203
- package/README.md +46 -0
- package/dist/index.d.mts +2084 -0
- package/dist/index.d.ts +2084 -0
- package/dist/index.js +3867 -0
- package/dist/index.mjs +3809 -0
- package/package.json +50 -15
- package/core/.changeset/README.md +0 -8
- package/core/.changeset/community-bootstrap-release.md +0 -17
- package/core/.changeset/config.json +0 -11
- package/core/.changeset/no-changelog.js +0 -16
- package/core/.changeset/pre.json +0 -17
- package/core/.editorconfig +0 -13
- package/core/.gitattributes +0 -2
- package/core/.github/CODE_OF_CONDUCT.md +0 -23
- package/core/.github/FUNDING.yml +0 -7
- package/core/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- package/core/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
- package/core/.github/PULL_REQUEST_TEMPLATE.md +0 -16
- package/core/.github/dependabot.yml +0 -16
- package/core/.github/workflows/autoapp.yml +0 -16
- package/core/.github/workflows/ci.yml +0 -187
- package/core/.github/workflows/codeql.yml +0 -30
- package/core/.github/workflows/deploy-docs.yml +0 -54
- package/core/.github/workflows/publish.yml +0 -43
- package/core/.lintstagedrc.json +0 -4
- package/core/.nvmrc +0 -1
- package/core/.prettierignore +0 -8
- package/core/.prettierrc +0 -11
- package/core/CONTRIBUTING.md +0 -70
- package/core/README.md +0 -61
- package/core/SECURITY.md +0 -21
- package/core/apps/docs/index.html +0 -28
- package/core/apps/docs/middleware.ts +0 -21
- package/core/apps/docs/package.json +0 -33
- package/core/apps/docs/public/@flux.png +0 -0
- package/core/apps/docs/public/docs/latest/guides.json +0 -1420
- package/core/apps/docs/public/docs/latest/main.json +0 -14981
- package/core/apps/docs/public/docs/latest/rag-index.json +0 -1
- package/core/apps/docs/public/docs/v1.0.5/guides.json +0 -226
- package/core/apps/docs/public/docs/v1.0.5/main.json +0 -7920
- package/core/apps/docs/public/docs/v1.0.6/guides.json +0 -226
- package/core/apps/docs/public/docs/v1.0.6/main.json +0 -7920
- package/core/apps/docs/public/docs/v1.0.7/guides.json +0 -259
- package/core/apps/docs/public/docs/v1.0.7/main.json +0 -8652
- package/core/apps/docs/public/docs/v1.0.8/guides.json +0 -313
- package/core/apps/docs/public/docs/v1.0.8/main.json +0 -9618
- package/core/apps/docs/public/docs/v1.0.9/guides.json +0 -319
- package/core/apps/docs/public/docs/v1.0.9/main.json +0 -10694
- package/core/apps/docs/public/docs/v1.1.0/guides.json +0 -589
- package/core/apps/docs/public/docs/v1.1.0/main.json +0 -12576
- package/core/apps/docs/public/docs/v1.1.2/guides.json +0 -650
- package/core/apps/docs/public/docs/v1.1.2/main.json +0 -13239
- package/core/apps/docs/public/docs/v1.1.3/guides.json +0 -650
- package/core/apps/docs/public/docs/v1.1.3/main.json +0 -13239
- package/core/apps/docs/public/docs/v1.1.4/guides.json +0 -708
- package/core/apps/docs/public/docs/v1.1.4/main.json +0 -13231
- package/core/apps/docs/public/docs/v1.1.5/guides.json +0 -1035
- package/core/apps/docs/public/docs/v1.1.5/main.json +0 -13838
- package/core/apps/docs/public/docs/v1.1.6/guides.json +0 -1041
- package/core/apps/docs/public/docs/v1.1.6/main.json +0 -14313
- package/core/apps/docs/public/docs/v1.1.8/guides.json +0 -1047
- package/core/apps/docs/public/docs/v1.1.8/main.json +0 -14421
- package/core/apps/docs/public/docs/v1.1.9/guides.json +0 -1047
- package/core/apps/docs/public/docs/v1.1.9/main.json +0 -14421
- package/core/apps/docs/public/docs/v1.2.0/guides.json +0 -1212
- package/core/apps/docs/public/docs/v1.2.0/main.json +0 -14663
- package/core/apps/docs/public/docs/v1.2.1/guides.json +0 -1293
- package/core/apps/docs/public/docs/v1.2.1/main.json +0 -14828
- package/core/apps/docs/public/docs/v1.2.2/guides.json +0 -1293
- package/core/apps/docs/public/docs/v1.2.2/main.json +0 -15025
- package/core/apps/docs/public/docs/v1.2.3/guides.json +0 -1420
- package/core/apps/docs/public/docs/v1.2.3/main.json +0 -14954
- package/core/apps/docs/public/docs/v1.2.4/guides.json +0 -1420
- package/core/apps/docs/public/docs/v1.2.4/main.json +0 -14981
- package/core/apps/docs/public/docs/versions.json +0 -24
- package/core/apps/docs/public/flux.png +0 -0
- package/core/apps/docs/public/locales/en.json +0 -50
- package/core/apps/docs/public/locales/guides-en.json +0 -512
- package/core/apps/docs/public/robots.txt +0 -4
- package/core/apps/docs/public/sitemap.xml +0 -33
- package/core/apps/docs/src/App.vue +0 -538
- package/core/apps/docs/src/components/ApiCategorySection.vue +0 -42
- package/core/apps/docs/src/components/ApiDiscordCompat.vue +0 -65
- package/core/apps/docs/src/components/ApiEndpointCard.vue +0 -313
- package/core/apps/docs/src/components/ApiSchemaBlock.vue +0 -131
- package/core/apps/docs/src/components/CodeBlock.vue +0 -177
- package/core/apps/docs/src/components/CommunityCallout.vue +0 -90
- package/core/apps/docs/src/components/ConstructorSection.vue +0 -82
- package/core/apps/docs/src/components/DocDescription.vue +0 -40
- package/core/apps/docs/src/components/FluxerLogo.vue +0 -3
- package/core/apps/docs/src/components/Footer.vue +0 -106
- package/core/apps/docs/src/components/GuideCodeBlock.vue +0 -102
- package/core/apps/docs/src/components/GuideDiscordCompat.vue +0 -77
- package/core/apps/docs/src/components/GuideDiscordCompatCallout.vue +0 -83
- package/core/apps/docs/src/components/GuideTable.vue +0 -77
- package/core/apps/docs/src/components/GuideTip.vue +0 -38
- package/core/apps/docs/src/components/MethodsSection.vue +0 -195
- package/core/apps/docs/src/components/ParamsTable.vue +0 -70
- package/core/apps/docs/src/components/PropertiesSection.vue +0 -143
- package/core/apps/docs/src/components/SearchBar.vue +0 -76
- package/core/apps/docs/src/components/SearchModal.vue +0 -361
- package/core/apps/docs/src/components/SidebarNav.vue +0 -225
- package/core/apps/docs/src/components/SponsorBanner.vue +0 -153
- package/core/apps/docs/src/components/TypeSignature.vue +0 -187
- package/core/apps/docs/src/components/VersionPicker.vue +0 -191
- package/core/apps/docs/src/composables/useSearchIndex.ts +0 -144
- package/core/apps/docs/src/composables/useVersionedPath.ts +0 -20
- package/core/apps/docs/src/data/apiEndpoints.ts +0 -1073
- package/core/apps/docs/src/data/changelog.ts +0 -717
- package/core/apps/docs/src/data/guides.ts +0 -2362
- package/core/apps/docs/src/env.d.ts +0 -7
- package/core/apps/docs/src/locales/guides-en.json +0 -512
- package/core/apps/docs/src/main.ts +0 -27
- package/core/apps/docs/src/pages/ApiReferenceLayout.vue +0 -175
- package/core/apps/docs/src/pages/ApiReferencePage.vue +0 -128
- package/core/apps/docs/src/pages/Changelog.vue +0 -288
- package/core/apps/docs/src/pages/ClassPage.vue +0 -319
- package/core/apps/docs/src/pages/ClassesList.vue +0 -100
- package/core/apps/docs/src/pages/DocsLayout.vue +0 -127
- package/core/apps/docs/src/pages/GuidePage.vue +0 -279
- package/core/apps/docs/src/pages/GuidesIndex.vue +0 -166
- package/core/apps/docs/src/pages/GuidesLayout.vue +0 -245
- package/core/apps/docs/src/pages/Home.vue +0 -125
- package/core/apps/docs/src/pages/NotFound.vue +0 -57
- package/core/apps/docs/src/pages/TypedefPage.vue +0 -230
- package/core/apps/docs/src/pages/TypedefsList.vue +0 -168
- package/core/apps/docs/src/pages/VersionLayout.vue +0 -15
- package/core/apps/docs/src/router.ts +0 -73
- package/core/apps/docs/src/stores/docs.ts +0 -54
- package/core/apps/docs/src/stores/guides.ts +0 -53
- package/core/apps/docs/src/stores/version.ts +0 -67
- package/core/apps/docs/src/styles/main.css +0 -278
- package/core/apps/docs/src/styles/prism.css +0 -95
- package/core/apps/docs/src/types/doc-schema.ts +0 -112
- package/core/apps/docs/tsconfig.json +0 -17
- package/core/apps/docs/tsconfig.node.json +0 -10
- package/core/apps/docs/vite.config.d.ts +0 -2
- package/core/apps/docs/vite.config.js +0 -26
- package/core/apps/docs/vite.config.ts +0 -28
- package/core/apps/docs-vitepress/.vitepress/config.ts +0 -141
- package/core/apps/docs-vitepress/api-data/latest/main.json +0 -15035
- package/core/apps/docs-vitepress/api-data/v1.2.4/main.json +0 -15035
- package/core/apps/docs-vitepress/api-data/versions.json +0 -6
- package/core/apps/docs-vitepress/index.md +0 -15
- package/core/apps/docs-vitepress/package-lock.json +0 -2924
- package/core/apps/docs-vitepress/package.json +0 -20
- package/core/apps/docs-vitepress/public/CNAME +0 -1
- package/core/apps/docs-vitepress/scripts/generate-api.ts +0 -243
- package/core/apps/docs-vitepress/scripts/migrate-guides.ts +0 -129
- package/core/apps/docs-vitepress/tsconfig.json +0 -11
- package/core/apps/docs-vitepress/v/latest/guides/attachments-by-url.md +0 -57
- package/core/apps/docs-vitepress/v/latest/guides/attachments.md +0 -62
- package/core/apps/docs-vitepress/v/latest/guides/basic-bot.md +0 -49
- package/core/apps/docs-vitepress/v/latest/guides/channels.md +0 -180
- package/core/apps/docs-vitepress/v/latest/guides/deprecated-apis.md +0 -58
- package/core/apps/docs-vitepress/v/latest/guides/discord-js-compatibility.md +0 -42
- package/core/apps/docs-vitepress/v/latest/guides/editing-embeds.md +0 -65
- package/core/apps/docs-vitepress/v/latest/guides/embed-media.md +0 -87
- package/core/apps/docs-vitepress/v/latest/guides/embeds.md +0 -166
- package/core/apps/docs-vitepress/v/latest/guides/emojis.md +0 -77
- package/core/apps/docs-vitepress/v/latest/guides/events.md +0 -202
- package/core/apps/docs-vitepress/v/latest/guides/gifs.md +0 -47
- package/core/apps/docs-vitepress/v/latest/guides/installation.md +0 -10
- package/core/apps/docs-vitepress/v/latest/guides/moderation.md +0 -89
- package/core/apps/docs-vitepress/v/latest/guides/permissions.md +0 -130
- package/core/apps/docs-vitepress/v/latest/guides/prefix-commands.md +0 -41
- package/core/apps/docs-vitepress/v/latest/guides/profile-urls.md +0 -58
- package/core/apps/docs-vitepress/v/latest/guides/reactions.md +0 -69
- package/core/apps/docs-vitepress/v/latest/guides/roles.md +0 -130
- package/core/apps/docs-vitepress/v/latest/guides/sending-without-reply.md +0 -172
- package/core/apps/docs-vitepress/v/latest/guides/voice.md +0 -109
- package/core/apps/docs-vitepress/v/latest/guides/wait-for-guilds.md +0 -37
- package/core/apps/docs-vitepress/v/latest/guides/webhook-attachments-embeds.md +0 -73
- package/core/apps/docs-vitepress/v/latest/guides/webhooks.md +0 -131
- package/core/eslint.config.js +0 -80
- package/core/examples/.env.example +0 -22
- package/core/examples/README.md +0 -68
- package/core/examples/first-steps-bot.js +0 -118
- package/core/examples/minimal-bot.js +0 -17
- package/core/examples/moderation-bot.js +0 -209
- package/core/examples/package.json +0 -14
- package/core/examples/ping-bot.js +0 -1146
- package/core/examples/reaction-bot.js +0 -70
- package/core/examples/reaction-roles-bot.js +0 -140
- package/core/examples/webhook-bot.js +0 -239
- package/core/flux.png +0 -0
- package/core/package.json +0 -78
- package/core/packages/builders/package.json +0 -51
- package/core/packages/builders/src/index.ts +0 -13
- package/core/packages/builders/src/messages/AttachmentBuilder.test.ts +0 -79
- package/core/packages/builders/src/messages/AttachmentBuilder.ts +0 -69
- package/core/packages/builders/src/messages/EmbedBuilder.test.ts +0 -266
- package/core/packages/builders/src/messages/EmbedBuilder.ts +0 -239
- package/core/packages/builders/src/messages/MessagePayload.test.ts +0 -118
- package/core/packages/builders/src/messages/MessagePayload.ts +0 -122
- package/core/packages/builders/tsconfig.json +0 -9
- package/core/packages/builders/tsup.config.ts +0 -9
- package/core/packages/builders/vitest.config.ts +0 -9
- package/core/packages/collection/package.json +0 -47
- package/core/packages/collection/src/Collection.test.ts +0 -232
- package/core/packages/collection/src/Collection.ts +0 -196
- package/core/packages/collection/src/index.ts +0 -1
- package/core/packages/collection/tsconfig.json +0 -9
- package/core/packages/collection/tsup.config.ts +0 -9
- package/core/packages/collection/vitest.config.ts +0 -9
- package/core/packages/docgen/package.json +0 -26
- package/core/packages/docgen/src/extract.ts +0 -262
- package/core/packages/docgen/src/formatType.ts +0 -24
- package/core/packages/docgen/src/index.ts +0 -103
- package/core/packages/docgen/src/schema.ts +0 -100
- package/core/packages/docgen/src/visitor.ts +0 -147
- package/core/packages/docgen/tsconfig.json +0 -9
- package/core/packages/docgen/tsup.config.ts +0 -9
- package/core/packages/fluxer-core/README.md +0 -26
- package/core/packages/fluxer-core/package.json +0 -60
- package/core/packages/fluxer-core/src/client/ChannelManager.ts +0 -143
- package/core/packages/fluxer-core/src/client/Client.gateway.test.ts +0 -84
- package/core/packages/fluxer-core/src/client/Client.resolveEmoji.test.ts +0 -45
- package/core/packages/fluxer-core/src/client/Client.ts +0 -558
- package/core/packages/fluxer-core/src/client/ClientUser.ts +0 -40
- package/core/packages/fluxer-core/src/client/EventHandlerRegistry.ts +0 -469
- package/core/packages/fluxer-core/src/client/GuildManager.ts +0 -79
- package/core/packages/fluxer-core/src/client/GuildMemberManager.ts +0 -91
- package/core/packages/fluxer-core/src/client/MessageManager.ts +0 -58
- package/core/packages/fluxer-core/src/client/UsersManager.ts +0 -122
- package/core/packages/fluxer-core/src/errors/ErrorCodes.test.ts +0 -19
- package/core/packages/fluxer-core/src/errors/ErrorCodes.ts +0 -12
- package/core/packages/fluxer-core/src/errors/FluxerError.test.ts +0 -32
- package/core/packages/fluxer-core/src/errors/FluxerError.ts +0 -15
- package/core/packages/fluxer-core/src/index.ts +0 -85
- package/core/packages/fluxer-core/src/structures/Base.ts +0 -7
- package/core/packages/fluxer-core/src/structures/Channel.ts +0 -508
- package/core/packages/fluxer-core/src/structures/Guild.test.ts +0 -189
- package/core/packages/fluxer-core/src/structures/Guild.ts +0 -734
- package/core/packages/fluxer-core/src/structures/GuildBan.ts +0 -35
- package/core/packages/fluxer-core/src/structures/GuildEmoji.ts +0 -57
- package/core/packages/fluxer-core/src/structures/GuildMember.test.ts +0 -203
- package/core/packages/fluxer-core/src/structures/GuildMember.ts +0 -213
- package/core/packages/fluxer-core/src/structures/GuildMemberRoleManager.ts +0 -121
- package/core/packages/fluxer-core/src/structures/GuildSticker.ts +0 -56
- package/core/packages/fluxer-core/src/structures/Invite.test.ts +0 -103
- package/core/packages/fluxer-core/src/structures/Invite.ts +0 -121
- package/core/packages/fluxer-core/src/structures/Message.test.ts +0 -109
- package/core/packages/fluxer-core/src/structures/Message.ts +0 -397
- package/core/packages/fluxer-core/src/structures/MessageReaction.ts +0 -72
- package/core/packages/fluxer-core/src/structures/PartialMessage.ts +0 -12
- package/core/packages/fluxer-core/src/structures/Role.test.ts +0 -77
- package/core/packages/fluxer-core/src/structures/Role.ts +0 -112
- package/core/packages/fluxer-core/src/structures/User.test.ts +0 -110
- package/core/packages/fluxer-core/src/structures/User.ts +0 -109
- package/core/packages/fluxer-core/src/structures/Webhook.test.ts +0 -109
- package/core/packages/fluxer-core/src/structures/Webhook.ts +0 -258
- package/core/packages/fluxer-core/src/util/Constants.test.ts +0 -16
- package/core/packages/fluxer-core/src/util/Constants.ts +0 -7
- package/core/packages/fluxer-core/src/util/Events.ts +0 -46
- package/core/packages/fluxer-core/src/util/MessageCollector.ts +0 -87
- package/core/packages/fluxer-core/src/util/Options.ts +0 -33
- package/core/packages/fluxer-core/src/util/ReactionCollector.ts +0 -116
- package/core/packages/fluxer-core/src/util/cdn.test.ts +0 -108
- package/core/packages/fluxer-core/src/util/cdn.ts +0 -130
- package/core/packages/fluxer-core/src/util/guildUtils.ts +0 -33
- package/core/packages/fluxer-core/src/util/messageUtils.test.ts +0 -74
- package/core/packages/fluxer-core/src/util/messageUtils.ts +0 -119
- package/core/packages/fluxer-core/src/util/permissions.test.ts +0 -95
- package/core/packages/fluxer-core/src/util/permissions.ts +0 -43
- package/core/packages/fluxer-core/tsconfig.json +0 -9
- package/core/packages/fluxer-core/tsup.config.ts +0 -9
- package/core/packages/fluxer-core/vitest.config.ts +0 -9
- package/core/packages/rest/package.json +0 -52
- package/core/packages/rest/src/REST.test.ts +0 -64
- package/core/packages/rest/src/REST.ts +0 -90
- package/core/packages/rest/src/RateLimitManager.test.ts +0 -71
- package/core/packages/rest/src/RateLimitManager.ts +0 -60
- package/core/packages/rest/src/RequestManager.test.ts +0 -87
- package/core/packages/rest/src/RequestManager.ts +0 -172
- package/core/packages/rest/src/errors/FluxerAPIError.test.ts +0 -57
- package/core/packages/rest/src/errors/FluxerAPIError.ts +0 -21
- package/core/packages/rest/src/errors/HTTPError.test.ts +0 -55
- package/core/packages/rest/src/errors/HTTPError.ts +0 -25
- package/core/packages/rest/src/errors/RateLimitError.test.ts +0 -41
- package/core/packages/rest/src/errors/RateLimitError.ts +0 -15
- package/core/packages/rest/src/errors/index.ts +0 -3
- package/core/packages/rest/src/index.ts +0 -6
- package/core/packages/rest/src/utils/constants.test.ts +0 -31
- package/core/packages/rest/src/utils/constants.ts +0 -5
- package/core/packages/rest/src/utils/files.test.ts +0 -37
- package/core/packages/rest/src/utils/files.ts +0 -75
- package/core/packages/rest/tsconfig.json +0 -9
- package/core/packages/rest/tsup.config.ts +0 -9
- package/core/packages/rest/vitest.config.ts +0 -9
- package/core/packages/types/package.json +0 -46
- package/core/packages/types/src/api/ban.ts +0 -8
- package/core/packages/types/src/api/channel.ts +0 -65
- package/core/packages/types/src/api/embed.ts +0 -82
- package/core/packages/types/src/api/emoji.ts +0 -12
- package/core/packages/types/src/api/errors.ts +0 -68
- package/core/packages/types/src/api/gateway.ts +0 -14
- package/core/packages/types/src/api/guild.ts +0 -123
- package/core/packages/types/src/api/index.ts +0 -15
- package/core/packages/types/src/api/instance.ts +0 -32
- package/core/packages/types/src/api/interaction.ts +0 -26
- package/core/packages/types/src/api/invite.ts +0 -28
- package/core/packages/types/src/api/message.ts +0 -140
- package/core/packages/types/src/api/role.ts +0 -41
- package/core/packages/types/src/api/sticker.ts +0 -14
- package/core/packages/types/src/api/user.ts +0 -79
- package/core/packages/types/src/api/webhook.ts +0 -41
- package/core/packages/types/src/common/index.ts +0 -1
- package/core/packages/types/src/common/snowflake.test.ts +0 -9
- package/core/packages/types/src/common/snowflake.ts +0 -8
- package/core/packages/types/src/gateway/events.ts +0 -189
- package/core/packages/types/src/gateway/index.ts +0 -3
- package/core/packages/types/src/gateway/opcodes.ts +0 -17
- package/core/packages/types/src/gateway/payloads.ts +0 -481
- package/core/packages/types/src/index.ts +0 -4
- package/core/packages/types/src/rest/index.ts +0 -1
- package/core/packages/types/src/rest/routes.test.ts +0 -169
- package/core/packages/types/src/rest/routes.ts +0 -109
- package/core/packages/types/tsconfig.json +0 -9
- package/core/packages/types/tsup.config.ts +0 -9
- package/core/packages/types/vitest.config.ts +0 -9
- package/core/packages/util/package.json +0 -51
- package/core/packages/util/src/BitField.test.ts +0 -96
- package/core/packages/util/src/BitField.ts +0 -105
- package/core/packages/util/src/MessageFlagsBitField.test.ts +0 -42
- package/core/packages/util/src/MessageFlagsBitField.ts +0 -20
- package/core/packages/util/src/PermissionsBitField.test.ts +0 -79
- package/core/packages/util/src/PermissionsBitField.ts +0 -97
- package/core/packages/util/src/SnowflakeUtil.test.ts +0 -69
- package/core/packages/util/src/SnowflakeUtil.ts +0 -65
- package/core/packages/util/src/UserFlagsBitField.test.ts +0 -39
- package/core/packages/util/src/UserFlagsBitField.ts +0 -48
- package/core/packages/util/src/deprecation.test.ts +0 -44
- package/core/packages/util/src/deprecation.ts +0 -28
- package/core/packages/util/src/emojiShortcodes.generated.ts +0 -5
- package/core/packages/util/src/emojiShortcodes.test.ts +0 -41
- package/core/packages/util/src/emojiShortcodes.ts +0 -22
- package/core/packages/util/src/formatters.test.ts +0 -65
- package/core/packages/util/src/formatters.ts +0 -35
- package/core/packages/util/src/index.ts +0 -34
- package/core/packages/util/src/resolvers.test.ts +0 -198
- package/core/packages/util/src/resolvers.ts +0 -127
- package/core/packages/util/src/tenorUtils.test.ts +0 -75
- package/core/packages/util/src/tenorUtils.ts +0 -86
- package/core/packages/util/tsconfig.json +0 -9
- package/core/packages/util/tsup.config.ts +0 -9
- package/core/packages/util/vitest.config.ts +0 -9
- package/core/packages/voice/README.md +0 -42
- package/core/packages/voice/package.json +0 -67
- package/core/packages/voice/src/LiveKitRtcConnection.receive.test.ts +0 -24
- package/core/packages/voice/src/LiveKitRtcConnection.ts +0 -1767
- package/core/packages/voice/src/VoiceConnection.ts +0 -413
- package/core/packages/voice/src/VoiceManager.receive.test.ts +0 -61
- package/core/packages/voice/src/VoiceManager.test.ts +0 -44
- package/core/packages/voice/src/VoiceManager.ts +0 -503
- package/core/packages/voice/src/exports.test.ts +0 -38
- package/core/packages/voice/src/index.ts +0 -51
- package/core/packages/voice/src/livekit.test.ts +0 -48
- package/core/packages/voice/src/livekit.ts +0 -33
- package/core/packages/voice/src/mp4box.d.ts +0 -32
- package/core/packages/voice/src/opusUtils.test.ts +0 -29
- package/core/packages/voice/src/opusUtils.ts +0 -86
- package/core/packages/voice/src/streamPreviewPlaceholder.test.ts +0 -16
- package/core/packages/voice/src/streamPreviewPlaceholder.ts +0 -8
- package/core/packages/voice/src/ws.d.ts +0 -1
- package/core/packages/voice/tsconfig.json +0 -5
- package/core/packages/voice/tsup.config.ts +0 -10
- package/core/packages/voice/vitest.config.ts +0 -9
- package/core/packages/ws/package.json +0 -52
- package/core/packages/ws/src/WebSocketManager.ts +0 -130
- package/core/packages/ws/src/WebSocketShard.ts +0 -296
- package/core/packages/ws/src/index.ts +0 -12
- package/core/packages/ws/src/utils/constants.test.ts +0 -46
- package/core/packages/ws/src/utils/constants.ts +0 -22
- package/core/packages/ws/src/utils/getWebSocket.ts +0 -55
- package/core/packages/ws/src/ws.d.ts +0 -10
- package/core/packages/ws/tsconfig.json +0 -9
- package/core/packages/ws/tsup.config.ts +0 -9
- package/core/pnpm-lock.yaml +0 -7033
- package/core/pnpm-workspace.yaml +0 -4
- package/core/scripts/generate-ai-rag.ts +0 -240
- package/core/scripts/generate-docs.ts +0 -143
- package/core/scripts/generate-emoji-shortcodes.ts +0 -58
- package/core/scripts/generate-types.ts +0 -6
- package/core/scripts/publish-ordered.js +0 -63
- package/core/scripts/test-cjs-require.mjs +0 -43
- package/core/scripts/test-esm-imports.mjs +0 -42
- package/core/scripts/test-package-exports.mjs +0 -98
- package/core/scripts/test-smoke.mjs +0 -103
- package/core/tsconfig.json +0 -18
- package/core/turbo.json +0 -30
- package/core/vitest.config.ts +0 -17
- package/core/wrangler.jsonc +0 -9
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Client, User } from '../';
|
|
3
|
-
|
|
4
|
-
function createMockClient() {
|
|
5
|
-
return {} as Client;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function createUser(
|
|
9
|
-
overrides: Partial<{
|
|
10
|
-
id: string;
|
|
11
|
-
username: string;
|
|
12
|
-
avatar: string | null;
|
|
13
|
-
banner: string | null;
|
|
14
|
-
}> = {},
|
|
15
|
-
) {
|
|
16
|
-
return new User(createMockClient(), {
|
|
17
|
-
id: overrides.id ?? '123456789012345678',
|
|
18
|
-
username: overrides.username ?? 'TestUser',
|
|
19
|
-
discriminator: '0',
|
|
20
|
-
avatar: overrides.avatar ?? null,
|
|
21
|
-
banner: overrides.banner ?? null,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('User', () => {
|
|
26
|
-
describe('toString()', () => {
|
|
27
|
-
it('returns user mention format', () => {
|
|
28
|
-
const user = createUser({ id: '987654321098765432' });
|
|
29
|
-
expect(user.toString()).toBe('<@987654321098765432>');
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('avatarURL()', () => {
|
|
34
|
-
it('returns null when avatar is null', () => {
|
|
35
|
-
const user = createUser({ avatar: null });
|
|
36
|
-
expect(user.avatarURL()).toBeNull();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('builds avatar URL with default png extension', () => {
|
|
40
|
-
const user = createUser({ avatar: 'abc123hash' });
|
|
41
|
-
const url = user.avatarURL();
|
|
42
|
-
expect(url).toContain('fluxerusercontent.com/avatars/123456789012345678/abc123hash.png');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('uses gif for animated avatar (a_ prefix)', () => {
|
|
46
|
-
const user = createUser({ avatar: 'a_animatedhash' });
|
|
47
|
-
const url = user.avatarURL();
|
|
48
|
-
expect(url).toContain('.gif');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('appends size when provided', () => {
|
|
52
|
-
const user = createUser({ avatar: 'hash' });
|
|
53
|
-
const url = user.avatarURL({ size: 256 });
|
|
54
|
-
expect(url).toContain('?size=256');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('displayAvatarURL()', () => {
|
|
59
|
-
it('returns default avatar URL when no custom avatar', () => {
|
|
60
|
-
const user = createUser({ avatar: null });
|
|
61
|
-
const url = user.displayAvatarURL();
|
|
62
|
-
expect(url).toContain('fluxerstatic.com/avatars/');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('returns custom avatar URL when avatar is set', () => {
|
|
66
|
-
const user = createUser({ avatar: 'custom' });
|
|
67
|
-
const url = user.displayAvatarURL();
|
|
68
|
-
expect(url).toContain('fluxerusercontent.com/avatars/');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('bannerURL()', () => {
|
|
73
|
-
it('returns null when banner is null', () => {
|
|
74
|
-
const user = createUser({ banner: null });
|
|
75
|
-
expect(user.bannerURL()).toBeNull();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('builds banner URL when banner is set', () => {
|
|
79
|
-
const user = createUser({ banner: 'bannerhash' });
|
|
80
|
-
const url = user.bannerURL();
|
|
81
|
-
expect(url).toContain('fluxerusercontent.com/banners/123456789012345678/bannerhash.png');
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('constructor', () => {
|
|
86
|
-
it('parses API user data', () => {
|
|
87
|
-
const user = createUser({
|
|
88
|
-
id: '111',
|
|
89
|
-
username: 'Alice',
|
|
90
|
-
avatar: 'av',
|
|
91
|
-
banner: 'bn',
|
|
92
|
-
});
|
|
93
|
-
expect(user.id).toBe('111');
|
|
94
|
-
expect(user.username).toBe('Alice');
|
|
95
|
-
expect(user.avatar).toBe('av');
|
|
96
|
-
expect(user.banner).toBe('bn');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('handles optional fields', () => {
|
|
100
|
-
const user = new User(createMockClient(), {
|
|
101
|
-
id: '1',
|
|
102
|
-
username: 'Bot',
|
|
103
|
-
discriminator: '0',
|
|
104
|
-
});
|
|
105
|
-
expect(user.globalName).toBeNull();
|
|
106
|
-
expect(user.avatar).toBeNull();
|
|
107
|
-
expect(user.bot).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Client } from '../client/Client.js';
|
|
2
|
-
import { Base } from './Base.js';
|
|
3
|
-
import { MessageSendOptions } from '../util/messageUtils.js';
|
|
4
|
-
import { APIChannelPartial, APIUserPartial } from '@erinjs/types';
|
|
5
|
-
import { Routes } from '@erinjs/types';
|
|
6
|
-
import { CDN_URL } from '../util/Constants.js';
|
|
7
|
-
import { cdnDefaultAvatarURL } from '../util/cdn.js';
|
|
8
|
-
import { DMChannel } from './Channel.js';
|
|
9
|
-
import { Message } from './Message';
|
|
10
|
-
|
|
11
|
-
/** Represents a user (or bot) on Fluxer. */
|
|
12
|
-
export class User extends Base {
|
|
13
|
-
readonly client: Client;
|
|
14
|
-
readonly id: string;
|
|
15
|
-
username: string;
|
|
16
|
-
discriminator: string;
|
|
17
|
-
globalName: string | null;
|
|
18
|
-
avatar: string | null;
|
|
19
|
-
readonly bot: boolean;
|
|
20
|
-
/** RGB avatar color (e.g. 7577782). Null if not set. */
|
|
21
|
-
avatarColor: number | null;
|
|
22
|
-
/** Public flags bitfield. Null if not set. */
|
|
23
|
-
flags: number | null;
|
|
24
|
-
/** Whether this is an official system user. */
|
|
25
|
-
readonly system: boolean;
|
|
26
|
-
/** Banner hash (from profile, member, or invite context). Null when not available. */
|
|
27
|
-
banner: string | null;
|
|
28
|
-
|
|
29
|
-
/** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
|
|
30
|
-
constructor(client: Client, data: APIUserPartial) {
|
|
31
|
-
super();
|
|
32
|
-
this.client = client;
|
|
33
|
-
this.id = data.id;
|
|
34
|
-
this.username = data.username;
|
|
35
|
-
this.discriminator = data.discriminator;
|
|
36
|
-
this.globalName = data.global_name ?? null;
|
|
37
|
-
this.avatar = data.avatar ?? null;
|
|
38
|
-
this.bot = !!data.bot;
|
|
39
|
-
this.avatarColor = data.avatar_color ?? null;
|
|
40
|
-
this.flags = data.flags ?? data.public_flags ?? null;
|
|
41
|
-
this.system = !!data.system;
|
|
42
|
-
this.banner = data.banner ?? null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Update mutable fields from fresh API data. Used by getOrCreateUser cache. */
|
|
46
|
-
_patch(data: APIUserPartial): void {
|
|
47
|
-
this.username = data.username;
|
|
48
|
-
this.discriminator = data.discriminator;
|
|
49
|
-
this.globalName = data.global_name ?? null;
|
|
50
|
-
this.avatar = data.avatar ?? null;
|
|
51
|
-
if (data.avatar_color !== undefined) this.avatarColor = data.avatar_color;
|
|
52
|
-
if (data.flags !== undefined) this.flags = data.flags;
|
|
53
|
-
if (data.banner !== undefined) this.banner = data.banner;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get the URL for this user's avatar.
|
|
58
|
-
* Auto-detects animated avatars (hash starting with `a_`) and uses gif extension.
|
|
59
|
-
* @param options - Optional `size` and `extension` (default: png, or gif for animated)
|
|
60
|
-
*/
|
|
61
|
-
avatarURL(options?: { size?: number; extension?: string }): string | null {
|
|
62
|
-
if (!this.avatar) return null;
|
|
63
|
-
const ext = this.avatar.startsWith('a_') ? 'gif' : (options?.extension ?? 'png');
|
|
64
|
-
const size = options?.size ? `?size=${options.size}` : '';
|
|
65
|
-
return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Get the avatar URL, or the default avatar if none set (Fluxer: fluxerstatic.com). */
|
|
69
|
-
displayAvatarURL(options?: { size?: number; extension?: string }): string {
|
|
70
|
-
return this.avatarURL(options) ?? cdnDefaultAvatarURL(this.id);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get the URL for this user's banner.
|
|
75
|
-
* Returns null if the user has no banner (only available when fetched from profile/member context).
|
|
76
|
-
*/
|
|
77
|
-
bannerURL(options?: { size?: number; extension?: string }): string | null {
|
|
78
|
-
if (!this.banner) return null;
|
|
79
|
-
const ext = this.banner.startsWith('a_') ? 'gif' : (options?.extension ?? 'png');
|
|
80
|
-
const size = options?.size ? `?size=${options.size}` : '';
|
|
81
|
-
return `${CDN_URL}/banners/${this.id}/${this.banner}.${ext}${size}`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Returns a mention string (e.g. `<@123456>`). */
|
|
85
|
-
toString(): string {
|
|
86
|
-
return `<@${this.id}>`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Create or get a DM channel with this user.
|
|
91
|
-
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
92
|
-
*/
|
|
93
|
-
async createDM(): Promise<DMChannel> {
|
|
94
|
-
const data = await this.client.rest.post(Routes.userMeChannels(), {
|
|
95
|
-
body: { recipient_id: this.id },
|
|
96
|
-
auth: true,
|
|
97
|
-
});
|
|
98
|
-
return new DMChannel(this.client, data as APIChannelPartial);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Send a DM to this user.
|
|
103
|
-
* Convenience method that creates the DM channel and sends the message.
|
|
104
|
-
*/
|
|
105
|
-
async send(options: MessageSendOptions): Promise<Message> {
|
|
106
|
-
const dm = await this.createDM();
|
|
107
|
-
return dm.send(options);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { Client, Webhook } from '../';
|
|
3
|
-
import { Routes } from '@erinjs/types';
|
|
4
|
-
|
|
5
|
-
function createMockClient() {
|
|
6
|
-
const get = vi.fn();
|
|
7
|
-
const del = vi.fn();
|
|
8
|
-
|
|
9
|
-
const client = {
|
|
10
|
-
rest: {
|
|
11
|
-
get,
|
|
12
|
-
delete: del,
|
|
13
|
-
post: vi.fn(),
|
|
14
|
-
patch: vi.fn(),
|
|
15
|
-
put: vi.fn(),
|
|
16
|
-
},
|
|
17
|
-
getOrCreateUser: (data: { id: string; username?: string; discriminator?: string }) => ({
|
|
18
|
-
id: data.id,
|
|
19
|
-
username: data.username ?? 'user',
|
|
20
|
-
discriminator: data.discriminator ?? '0',
|
|
21
|
-
}),
|
|
22
|
-
} as unknown as Client;
|
|
23
|
-
|
|
24
|
-
return { client, get, del };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function createWebhook(client: Client, token: string | null = 'token123') {
|
|
28
|
-
const data = {
|
|
29
|
-
id: 'webhook1',
|
|
30
|
-
guild_id: 'guild1',
|
|
31
|
-
channel_id: 'channel1',
|
|
32
|
-
name: 'Test Webhook',
|
|
33
|
-
avatar: null,
|
|
34
|
-
user: {
|
|
35
|
-
id: 'user1',
|
|
36
|
-
username: 'WebhookUser',
|
|
37
|
-
discriminator: '0',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return new Webhook(client, {
|
|
42
|
-
...data,
|
|
43
|
-
...(token ? { token } : {}),
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const mockMessagePayload = {
|
|
48
|
-
id: 'message1',
|
|
49
|
-
channel_id: 'channel1',
|
|
50
|
-
author: {
|
|
51
|
-
id: 'user1',
|
|
52
|
-
username: 'WebhookUser',
|
|
53
|
-
discriminator: '0',
|
|
54
|
-
},
|
|
55
|
-
type: 0,
|
|
56
|
-
flags: 0,
|
|
57
|
-
content: 'hello',
|
|
58
|
-
timestamp: new Date().toISOString(),
|
|
59
|
-
edited_timestamp: null,
|
|
60
|
-
pinned: false,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
describe('Webhook', () => {
|
|
64
|
-
describe('fetchMessage()', () => {
|
|
65
|
-
it('fetches a webhook message using token auth route', async () => {
|
|
66
|
-
const { client, get } = createMockClient();
|
|
67
|
-
get.mockResolvedValue(mockMessagePayload);
|
|
68
|
-
const webhook = createWebhook(client);
|
|
69
|
-
|
|
70
|
-
const message = await webhook.fetchMessage('message1');
|
|
71
|
-
|
|
72
|
-
expect(get).toHaveBeenCalledWith(Routes.webhookMessage('webhook1', 'token123', 'message1'), {
|
|
73
|
-
auth: false,
|
|
74
|
-
});
|
|
75
|
-
expect(message.id).toBe('message1');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('throws when token is unavailable', async () => {
|
|
79
|
-
const { client } = createMockClient();
|
|
80
|
-
const webhook = createWebhook(client, null);
|
|
81
|
-
|
|
82
|
-
await expect(webhook.fetchMessage('message1')).rejects.toThrow(
|
|
83
|
-
'Webhook token is required to fetch messages',
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('deleteMessage()', () => {
|
|
89
|
-
it('deletes a webhook message using token auth route', async () => {
|
|
90
|
-
const { client, del } = createMockClient();
|
|
91
|
-
const webhook = createWebhook(client);
|
|
92
|
-
|
|
93
|
-
await webhook.deleteMessage('message1');
|
|
94
|
-
|
|
95
|
-
expect(del).toHaveBeenCalledWith(Routes.webhookMessage('webhook1', 'token123', 'message1'), {
|
|
96
|
-
auth: false,
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('throws when token is unavailable', async () => {
|
|
101
|
-
const { client } = createMockClient();
|
|
102
|
-
const webhook = createWebhook(client, null);
|
|
103
|
-
|
|
104
|
-
await expect(webhook.deleteMessage('message1')).rejects.toThrow(
|
|
105
|
-
'Webhook token is required to delete messages',
|
|
106
|
-
);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { Client } from '../client/Client.js';
|
|
2
|
-
import { Base } from './Base.js';
|
|
3
|
-
import { APIEmbed, APIMessage } from '@erinjs/types';
|
|
4
|
-
import {
|
|
5
|
-
APIWebhook,
|
|
6
|
-
APIWebhookUpdateRequest,
|
|
7
|
-
APIWebhookTokenUpdateRequest,
|
|
8
|
-
APIWebhookEditMessageRequest,
|
|
9
|
-
} from '@erinjs/types';
|
|
10
|
-
import { Routes } from '@erinjs/types';
|
|
11
|
-
import { EmbedBuilder } from '@erinjs/builders';
|
|
12
|
-
import { buildSendBody, resolveMessageFiles, type MessageFileData } from '../util/messageUtils.js';
|
|
13
|
-
import { Message } from './Message.js';
|
|
14
|
-
import { User } from './User.js';
|
|
15
|
-
import { cdnAvatarURL } from '../util/cdn.js';
|
|
16
|
-
|
|
17
|
-
/** File data for webhook attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
|
|
18
|
-
export type WebhookFileData = MessageFileData;
|
|
19
|
-
|
|
20
|
-
/** Attachment metadata for webhook file uploads (id matches FormData index). */
|
|
21
|
-
export interface WebhookAttachmentMeta {
|
|
22
|
-
id: number;
|
|
23
|
-
filename: string;
|
|
24
|
-
title?: string | null;
|
|
25
|
-
description?: string | null;
|
|
26
|
-
/** MessageAttachmentFlags: IS_SPOILER (8), CONTAINS_EXPLICIT_MEDIA (16), IS_ANIMATED (32) */
|
|
27
|
-
flags?: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Options for sending a message via webhook. Aligns with WebhookMessageRequest in the API. */
|
|
31
|
-
export interface WebhookSendOptions {
|
|
32
|
-
/** Message text content (up to 2000 characters) */
|
|
33
|
-
content?: string;
|
|
34
|
-
/** Embed objects. Use EmbedBuilder or APIEmbed; EmbedBuilder is serialized automatically. */
|
|
35
|
-
embeds?: (APIEmbed | EmbedBuilder)[];
|
|
36
|
-
/** Override the webhook's default username for this message */
|
|
37
|
-
username?: string;
|
|
38
|
-
/** Override the webhook's default avatar URL for this message */
|
|
39
|
-
avatar_url?: string;
|
|
40
|
-
/** Text-to-speech */
|
|
41
|
-
tts?: boolean;
|
|
42
|
-
/** File attachments. When present, uses multipart/form-data (same as channel.send). */
|
|
43
|
-
files?: WebhookFileData[];
|
|
44
|
-
/** Attachment metadata for files (id = index). Use when files are provided. */
|
|
45
|
-
attachments?: WebhookAttachmentMeta[];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Represents a Discord/Fluxer webhook. Supports creating, fetching, sending, and deleting.
|
|
50
|
-
* The token is only available when the webhook was created; fetched webhooks cannot send messages.
|
|
51
|
-
*/
|
|
52
|
-
export class Webhook extends Base {
|
|
53
|
-
readonly client: Client;
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly guildId: string;
|
|
56
|
-
channelId: string;
|
|
57
|
-
name: string;
|
|
58
|
-
avatar: string | null;
|
|
59
|
-
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
60
|
-
readonly token: string | null;
|
|
61
|
-
/** User who created the webhook. */
|
|
62
|
-
readonly user: User;
|
|
63
|
-
|
|
64
|
-
/** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
|
|
65
|
-
constructor(client: Client, data: APIWebhook & { token?: string | null }) {
|
|
66
|
-
super();
|
|
67
|
-
this.client = client;
|
|
68
|
-
this.id = data.id;
|
|
69
|
-
this.guildId = data.guild_id;
|
|
70
|
-
this.channelId = data.channel_id;
|
|
71
|
-
this.name = data.name ?? 'Unknown';
|
|
72
|
-
this.avatar = data.avatar ?? null;
|
|
73
|
-
this.token = data.token ?? null;
|
|
74
|
-
this.user = client.getOrCreateUser(data.user);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get the URL for this webhook's avatar.
|
|
79
|
-
* Returns null if the webhook has no custom avatar.
|
|
80
|
-
*/
|
|
81
|
-
avatarURL(options?: { size?: number; extension?: string }): string | null {
|
|
82
|
-
return cdnAvatarURL(this.id, this.avatar, options);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
86
|
-
async delete(): Promise<void> {
|
|
87
|
-
await this.client.rest.delete(Routes.webhook(this.id), { auth: true });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
|
|
92
|
-
* @param options - Fields to update (name, avatar, channel_id when using bot auth)
|
|
93
|
-
* @returns This webhook instance with updated fields
|
|
94
|
-
*/
|
|
95
|
-
async edit(options: APIWebhookUpdateRequest | APIWebhookTokenUpdateRequest): Promise<Webhook> {
|
|
96
|
-
const body: Record<string, unknown> = {};
|
|
97
|
-
if (options.name !== undefined) body.name = options.name;
|
|
98
|
-
if (options.avatar !== undefined) body.avatar = options.avatar;
|
|
99
|
-
if ('channel_id' in options && options.channel_id !== undefined && !this.token) {
|
|
100
|
-
body.channel_id = options.channel_id;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (this.token) {
|
|
104
|
-
const data = await this.client.rest.patch(Routes.webhookExecute(this.id, this.token), {
|
|
105
|
-
body,
|
|
106
|
-
auth: false,
|
|
107
|
-
});
|
|
108
|
-
const w = data as APIWebhook;
|
|
109
|
-
this.name = w.name ?? this.name;
|
|
110
|
-
this.avatar = w.avatar ?? null;
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const data = await this.client.rest.patch(Routes.webhook(this.id), {
|
|
115
|
-
body,
|
|
116
|
-
auth: true,
|
|
117
|
-
});
|
|
118
|
-
const w = data as APIWebhook;
|
|
119
|
-
this.name = w.name ?? this.name;
|
|
120
|
-
this.avatar = w.avatar ?? null;
|
|
121
|
-
this.channelId = w.channel_id ?? this.channelId;
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
|
|
127
|
-
* @param options - Text content or object with content, embeds, username, avatar_url, tts, files, attachments
|
|
128
|
-
* @param wait - If true, waits for the API and returns the created Message; otherwise returns void (204)
|
|
129
|
-
* @throws Error if token is not available
|
|
130
|
-
* @example
|
|
131
|
-
* await webhook.send('Hello!');
|
|
132
|
-
* await webhook.send({ embeds: [embed] });
|
|
133
|
-
* await webhook.send({ content: 'File attached', files: [{ name: 'data.txt', data: buffer }] });
|
|
134
|
-
* const msg = await webhook.send({ content: 'Hi' }, true);
|
|
135
|
-
*/
|
|
136
|
-
async send(options: string | WebhookSendOptions, wait?: boolean): Promise<Message | undefined> {
|
|
137
|
-
if (!this.token) {
|
|
138
|
-
throw new Error(
|
|
139
|
-
'Webhook token is required to send. The token is only returned when creating a webhook; fetched webhooks cannot send.',
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
const opts = typeof options === 'string' ? { content: options } : options;
|
|
143
|
-
|
|
144
|
-
// Use same body-building flow as ChannelManager.send / message send
|
|
145
|
-
const body = buildSendBody(opts) as Record<string, unknown>;
|
|
146
|
-
if (opts.username !== undefined) body.username = opts.username;
|
|
147
|
-
if (opts.avatar_url !== undefined) body.avatar_url = opts.avatar_url;
|
|
148
|
-
if (opts.tts !== undefined) body.tts = opts.tts;
|
|
149
|
-
|
|
150
|
-
const route = Routes.webhookExecute(this.id, this.token) + (wait ? '?wait=true' : '');
|
|
151
|
-
|
|
152
|
-
// Same pattern as ChannelManager: { body, files } when files present (URLs resolved automatically)
|
|
153
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : undefined;
|
|
154
|
-
const postOptions = files?.length
|
|
155
|
-
? { body, files, auth: false as const }
|
|
156
|
-
: { body, auth: false as const };
|
|
157
|
-
|
|
158
|
-
const data = await this.client.rest.post<APIMessage | undefined>(route, postOptions);
|
|
159
|
-
|
|
160
|
-
if (wait && data) {
|
|
161
|
-
return new Message(this.client, data);
|
|
162
|
-
}
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Edit a message previously sent by this webhook.
|
|
168
|
-
* Requires the webhook token.
|
|
169
|
-
* @param messageId - The ID of the message to edit
|
|
170
|
-
* @param options - Fields to update (content, embeds, attachments)
|
|
171
|
-
* @returns The updated Message
|
|
172
|
-
* @throws Error if token is not available
|
|
173
|
-
*/
|
|
174
|
-
async editMessage(messageId: string, options: APIWebhookEditMessageRequest): Promise<Message> {
|
|
175
|
-
if (!this.token) {
|
|
176
|
-
throw new Error(
|
|
177
|
-
'Webhook token is required to edit messages. The token is only returned when creating a webhook; fetched webhooks cannot edit messages.',
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
const data = await this.client.rest.patch<APIMessage>(
|
|
181
|
-
Routes.webhookMessage(this.id, this.token, messageId),
|
|
182
|
-
{ body: options as Record<string, unknown>, auth: false },
|
|
183
|
-
);
|
|
184
|
-
return new Message(this.client, data);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Fetch a message sent by this webhook.
|
|
189
|
-
* Requires the webhook token.
|
|
190
|
-
* @param messageId - The ID of the message to fetch
|
|
191
|
-
* @returns The message
|
|
192
|
-
* @throws Error if token is not available
|
|
193
|
-
*/
|
|
194
|
-
async fetchMessage(messageId: string): Promise<Message> {
|
|
195
|
-
if (!this.token) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
'Webhook token is required to fetch messages. The token is only returned when creating a webhook; fetched webhooks cannot fetch messages.',
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
const data = await this.client.rest.get<APIMessage>(
|
|
201
|
-
Routes.webhookMessage(this.id, this.token, messageId),
|
|
202
|
-
{ auth: false },
|
|
203
|
-
);
|
|
204
|
-
return new Message(this.client, data);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Delete a message sent by this webhook.
|
|
209
|
-
* Requires the webhook token.
|
|
210
|
-
* @param messageId - The ID of the message to delete
|
|
211
|
-
* @throws Error if token is not available
|
|
212
|
-
*/
|
|
213
|
-
async deleteMessage(messageId: string): Promise<void> {
|
|
214
|
-
if (!this.token) {
|
|
215
|
-
throw new Error(
|
|
216
|
-
'Webhook token is required to delete messages. The token is only returned when creating a webhook; fetched webhooks cannot delete messages.',
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
await this.client.rest.delete(Routes.webhookMessage(this.id, this.token, messageId), {
|
|
220
|
-
auth: false,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Fetch a webhook by ID using bot auth.
|
|
226
|
-
* @param client - The client instance
|
|
227
|
-
* @param webhookId - The webhook ID
|
|
228
|
-
* @returns Webhook without token (cannot send)
|
|
229
|
-
*/
|
|
230
|
-
static async fetch(client: Client, webhookId: string): Promise<Webhook> {
|
|
231
|
-
const data = await client.rest.get(Routes.webhook(webhookId));
|
|
232
|
-
return new Webhook(client, data as APIWebhook);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
237
|
-
* @param client - The client instance
|
|
238
|
-
* @param webhookId - The webhook ID
|
|
239
|
-
* @param token - The webhook token (from createWebhook or stored)
|
|
240
|
-
* @param options - Optional channelId, guildId, name for display
|
|
241
|
-
*/
|
|
242
|
-
static fromToken(
|
|
243
|
-
client: Client,
|
|
244
|
-
webhookId: string,
|
|
245
|
-
token: string,
|
|
246
|
-
options?: { channelId?: string; guildId?: string; name?: string },
|
|
247
|
-
): Webhook {
|
|
248
|
-
return new Webhook(client, {
|
|
249
|
-
id: webhookId,
|
|
250
|
-
guild_id: options?.guildId ?? '',
|
|
251
|
-
channel_id: options?.channelId ?? '',
|
|
252
|
-
name: options?.name ?? 'Webhook',
|
|
253
|
-
avatar: null,
|
|
254
|
-
token,
|
|
255
|
-
user: { id: '', username: 'webhook', discriminator: '0' },
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { CDN_URL, STATIC_CDN_URL, DEFAULT_USER_AGENT } from './Constants.js';
|
|
3
|
-
|
|
4
|
-
describe('Constants', () => {
|
|
5
|
-
it('CDN_URL points to fluxerusercontent', () => {
|
|
6
|
-
expect(CDN_URL).toBe('https://fluxerusercontent.com');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('STATIC_CDN_URL points to fluxerstatic', () => {
|
|
10
|
-
expect(STATIC_CDN_URL).toBe('https://fluxerstatic.com');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('DEFAULT_USER_AGENT is erin.js', () => {
|
|
14
|
-
expect(DEFAULT_USER_AGENT).toBe('erin.js');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** User Content CDN (avatars, icons, banners, emojis, attachments). */
|
|
2
|
-
export const CDN_URL = 'https://fluxerusercontent.com';
|
|
3
|
-
|
|
4
|
-
/** Static Assets CDN (default avatars). Use fluxerstatic.com for default avatars per Fluxer API. */
|
|
5
|
-
export const STATIC_CDN_URL = 'https://fluxerstatic.com';
|
|
6
|
-
|
|
7
|
-
export const DEFAULT_USER_AGENT = 'erin.js';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** Event name constants for client.on(Events.X, handler). Use with ClientEvents for typed callbacks. */
|
|
2
|
-
export const Events = {
|
|
3
|
-
Ready: 'ready',
|
|
4
|
-
MessageCreate: 'messageCreate',
|
|
5
|
-
MessageUpdate: 'messageUpdate',
|
|
6
|
-
MessageDelete: 'messageDelete',
|
|
7
|
-
MessageDeleteBulk: 'messageDeleteBulk',
|
|
8
|
-
MessageReactionAdd: 'messageReactionAdd',
|
|
9
|
-
MessageReactionRemove: 'messageReactionRemove',
|
|
10
|
-
MessageReactionRemoveAll: 'messageReactionRemoveAll',
|
|
11
|
-
MessageReactionRemoveEmoji: 'messageReactionRemoveEmoji',
|
|
12
|
-
InteractionCreate: 'interactionCreate',
|
|
13
|
-
GuildCreate: 'guildCreate',
|
|
14
|
-
GuildUpdate: 'guildUpdate',
|
|
15
|
-
GuildDelete: 'guildDelete',
|
|
16
|
-
GuildBanAdd: 'guildBanAdd',
|
|
17
|
-
GuildBanRemove: 'guildBanRemove',
|
|
18
|
-
GuildEmojisUpdate: 'guildEmojisUpdate',
|
|
19
|
-
GuildStickersUpdate: 'guildStickersUpdate',
|
|
20
|
-
GuildIntegrationsUpdate: 'guildIntegrationsUpdate',
|
|
21
|
-
GuildMemberAdd: 'guildMemberAdd',
|
|
22
|
-
GuildMemberUpdate: 'guildMemberUpdate',
|
|
23
|
-
GuildMemberRemove: 'guildMemberRemove',
|
|
24
|
-
GuildRoleCreate: 'guildRoleCreate',
|
|
25
|
-
GuildRoleUpdate: 'guildRoleUpdate',
|
|
26
|
-
GuildRoleDelete: 'guildRoleDelete',
|
|
27
|
-
GuildScheduledEventCreate: 'guildScheduledEventCreate',
|
|
28
|
-
GuildScheduledEventUpdate: 'guildScheduledEventUpdate',
|
|
29
|
-
GuildScheduledEventDelete: 'guildScheduledEventDelete',
|
|
30
|
-
ChannelCreate: 'channelCreate',
|
|
31
|
-
ChannelUpdate: 'channelUpdate',
|
|
32
|
-
ChannelDelete: 'channelDelete',
|
|
33
|
-
ChannelPinsUpdate: 'channelPinsUpdate',
|
|
34
|
-
InviteCreate: 'inviteCreate',
|
|
35
|
-
InviteDelete: 'inviteDelete',
|
|
36
|
-
TypingStart: 'typingStart',
|
|
37
|
-
UserUpdate: 'userUpdate',
|
|
38
|
-
PresenceUpdate: 'presenceUpdate',
|
|
39
|
-
VoiceStateUpdate: 'voiceStateUpdate',
|
|
40
|
-
VoiceServerUpdate: 'voiceServerUpdate',
|
|
41
|
-
VoiceStatesSync: 'voiceStatesSync',
|
|
42
|
-
WebhooksUpdate: 'webhooksUpdate',
|
|
43
|
-
Resumed: 'resumed',
|
|
44
|
-
Error: 'error',
|
|
45
|
-
Debug: 'debug',
|
|
46
|
-
} as const;
|