@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,35 +0,0 @@
|
|
|
1
|
-
import { Client } from '../client/Client.js';
|
|
2
|
-
import { Base } from './Base.js';
|
|
3
|
-
import { APIBan } from '@erinjs/types';
|
|
4
|
-
import { Routes } from '@erinjs/types';
|
|
5
|
-
import { User } from './User.js';
|
|
6
|
-
|
|
7
|
-
/** Represents a ban in a guild. */
|
|
8
|
-
export class GuildBan extends Base {
|
|
9
|
-
readonly client: Client;
|
|
10
|
-
readonly guildId: string;
|
|
11
|
-
readonly user: User;
|
|
12
|
-
readonly reason: string | null;
|
|
13
|
-
/** ISO timestamp when a temporary ban expires. Null for permanent bans. */
|
|
14
|
-
readonly expiresAt: string | null;
|
|
15
|
-
|
|
16
|
-
/** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
|
|
17
|
-
constructor(client: Client, data: APIBan & { guild_id?: string }, guildId: string) {
|
|
18
|
-
super();
|
|
19
|
-
this.client = client;
|
|
20
|
-
this.guildId = data.guild_id ?? guildId;
|
|
21
|
-
this.user = client.getOrCreateUser(data.user);
|
|
22
|
-
this.reason = data.reason ?? null;
|
|
23
|
-
this.expiresAt = data.expires_at ?? null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Remove this ban (unban the user).
|
|
28
|
-
* Requires Ban Members permission.
|
|
29
|
-
*/
|
|
30
|
-
async unban(): Promise<void> {
|
|
31
|
-
await this.client.rest.delete(Routes.guildBan(this.guildId, this.user.id), {
|
|
32
|
-
auth: true,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Client } from '../client/Client.js';
|
|
2
|
-
import { Base } from './Base.js';
|
|
3
|
-
import { APIEmoji } from '@erinjs/types';
|
|
4
|
-
import { Routes } from '@erinjs/types';
|
|
5
|
-
import { CDN_URL } from '../util/Constants.js';
|
|
6
|
-
|
|
7
|
-
/** Represents a custom emoji in a guild. */
|
|
8
|
-
export class GuildEmoji extends Base {
|
|
9
|
-
readonly client: Client;
|
|
10
|
-
readonly id: string;
|
|
11
|
-
readonly guildId: string;
|
|
12
|
-
name: string;
|
|
13
|
-
readonly animated: boolean;
|
|
14
|
-
|
|
15
|
-
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
16
|
-
constructor(client: Client, data: APIEmoji & { guild_id?: string }, guildId: string) {
|
|
17
|
-
super();
|
|
18
|
-
this.client = client;
|
|
19
|
-
this.id = data.id;
|
|
20
|
-
this.guildId = data.guild_id ?? guildId;
|
|
21
|
-
this.name = data.name;
|
|
22
|
-
this.animated = data.animated ?? false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** CDN URL for this emoji image. */
|
|
26
|
-
get url(): string {
|
|
27
|
-
const ext = this.animated ? 'gif' : 'png';
|
|
28
|
-
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Emoji identifier for use in reactions: `name:id` */
|
|
32
|
-
get identifier(): string {
|
|
33
|
-
return `${this.name}:${this.id}`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
37
|
-
async delete(): Promise<void> {
|
|
38
|
-
await this.client.rest.delete(Routes.guildEmoji(this.guildId, this.id), {
|
|
39
|
-
auth: true,
|
|
40
|
-
});
|
|
41
|
-
const guild = this.client.guilds.get(this.guildId);
|
|
42
|
-
if (guild) guild.emojis.delete(this.id);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Edit this emoji's name.
|
|
47
|
-
* Requires Manage Emojis and Stickers permission.
|
|
48
|
-
*/
|
|
49
|
-
async edit(options: { name: string }): Promise<GuildEmoji> {
|
|
50
|
-
const data = await this.client.rest.patch(Routes.guildEmoji(this.guildId, this.id), {
|
|
51
|
-
body: options,
|
|
52
|
-
auth: true,
|
|
53
|
-
});
|
|
54
|
-
this.name = (data as APIEmoji).name;
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Guild, Client, User, GuildMember } from '../';
|
|
3
|
-
|
|
4
|
-
function createMockClient() {
|
|
5
|
-
const client = {
|
|
6
|
-
getOrCreateUser: (data: {
|
|
7
|
-
id: string;
|
|
8
|
-
username: string;
|
|
9
|
-
discriminator: string;
|
|
10
|
-
global_name?: string | null;
|
|
11
|
-
}) => new User(client as Client, data),
|
|
12
|
-
};
|
|
13
|
-
return client as Client;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function createMockGuild(client: ReturnType<typeof createMockClient>) {
|
|
17
|
-
return new Guild(client as never, {
|
|
18
|
-
id: 'guild123',
|
|
19
|
-
name: 'Test Guild',
|
|
20
|
-
icon: null,
|
|
21
|
-
banner: null,
|
|
22
|
-
owner_id: 'owner1',
|
|
23
|
-
features: [],
|
|
24
|
-
afk_timeout: 0,
|
|
25
|
-
nsfw_level: 0,
|
|
26
|
-
verification_level: 0,
|
|
27
|
-
mfa_level: 0,
|
|
28
|
-
explicit_content_filter: 0,
|
|
29
|
-
default_message_notifications: 0,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function createMember(
|
|
34
|
-
overrides: {
|
|
35
|
-
nick?: string | null;
|
|
36
|
-
user?: { username?: string; global_name?: string | null };
|
|
37
|
-
} = {},
|
|
38
|
-
) {
|
|
39
|
-
const client = createMockClient();
|
|
40
|
-
const guild = createMockGuild(client);
|
|
41
|
-
return new GuildMember(
|
|
42
|
-
client as never,
|
|
43
|
-
{
|
|
44
|
-
user: {
|
|
45
|
-
id: 'user1',
|
|
46
|
-
username: overrides.user?.username ?? 'TestUser',
|
|
47
|
-
discriminator: '0',
|
|
48
|
-
global_name: overrides.user?.global_name ?? null,
|
|
49
|
-
},
|
|
50
|
-
nick: overrides.nick ?? null,
|
|
51
|
-
roles: [],
|
|
52
|
-
joined_at: new Date().toISOString(),
|
|
53
|
-
},
|
|
54
|
-
guild,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
describe('GuildMember', () => {
|
|
59
|
-
describe('displayName', () => {
|
|
60
|
-
it('returns nickname when set', () => {
|
|
61
|
-
const member = createMember({ nick: 'ServerNick' });
|
|
62
|
-
expect(member.displayName).toBe('ServerNick');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('returns global name when no nick', () => {
|
|
66
|
-
const member = createMember({
|
|
67
|
-
nick: null,
|
|
68
|
-
user: { username: 'alice', global_name: 'Alice Display' },
|
|
69
|
-
});
|
|
70
|
-
expect(member.displayName).toBe('Alice Display');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('returns username when no nick or global name', () => {
|
|
74
|
-
const member = createMember({
|
|
75
|
-
nick: null,
|
|
76
|
-
user: { username: 'bob', global_name: null },
|
|
77
|
-
});
|
|
78
|
-
expect(member.displayName).toBe('bob');
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('avatarURL()', () => {
|
|
83
|
-
it('returns null when member has no guild avatar', () => {
|
|
84
|
-
const member = createMember();
|
|
85
|
-
expect(member.avatar).toBeNull();
|
|
86
|
-
expect(member.avatarURL()).toBeNull();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('builds member avatar URL when avatar is set', () => {
|
|
90
|
-
const client = createMockClient();
|
|
91
|
-
const guild = createMockGuild(client);
|
|
92
|
-
const member = new GuildMember(
|
|
93
|
-
client as never,
|
|
94
|
-
{
|
|
95
|
-
user: { id: 'u1', username: 'Test', discriminator: '0' },
|
|
96
|
-
nick: null,
|
|
97
|
-
avatar: 'memberavatar',
|
|
98
|
-
roles: [],
|
|
99
|
-
joined_at: new Date().toISOString(),
|
|
100
|
-
},
|
|
101
|
-
guild,
|
|
102
|
-
);
|
|
103
|
-
const url = member.avatarURL();
|
|
104
|
-
expect(url).toContain('guilds/guild123/users/u1/avatars/memberavatar');
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('displayAvatarURL()', () => {
|
|
109
|
-
it('falls back to user avatar when no guild avatar', () => {
|
|
110
|
-
const client = createMockClient();
|
|
111
|
-
const guild = createMockGuild(client);
|
|
112
|
-
const member = new GuildMember(
|
|
113
|
-
client as never,
|
|
114
|
-
{
|
|
115
|
-
user: {
|
|
116
|
-
id: 'u1',
|
|
117
|
-
username: 'Test',
|
|
118
|
-
discriminator: '0',
|
|
119
|
-
avatar: 'useravatar',
|
|
120
|
-
},
|
|
121
|
-
nick: null,
|
|
122
|
-
avatar: null,
|
|
123
|
-
roles: [],
|
|
124
|
-
joined_at: new Date().toISOString(),
|
|
125
|
-
},
|
|
126
|
-
guild,
|
|
127
|
-
);
|
|
128
|
-
const url = member.displayAvatarURL();
|
|
129
|
-
expect(url).toContain('avatars/u1/useravatar');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('move()', () => {
|
|
134
|
-
it('calls edit with channel_id to move member', async () => {
|
|
135
|
-
const member = createMember();
|
|
136
|
-
let editCalled: boolean = false;
|
|
137
|
-
let editParams: { channel_id: string | null; connection_id?: string | null } | undefined;
|
|
138
|
-
|
|
139
|
-
member.edit = async (params: {
|
|
140
|
-
channel_id: string | null;
|
|
141
|
-
connection_id?: string | null;
|
|
142
|
-
}) => {
|
|
143
|
-
editCalled = true;
|
|
144
|
-
editParams = params;
|
|
145
|
-
return member;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
await member.move('voicechannel123');
|
|
149
|
-
|
|
150
|
-
expect(editCalled).toBe(true);
|
|
151
|
-
expect(editParams).toEqual({
|
|
152
|
-
channel_id: 'voicechannel123',
|
|
153
|
-
connection_id: undefined,
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('calls edit with null to disconnect member', async () => {
|
|
158
|
-
const member = createMember();
|
|
159
|
-
let editCalled: boolean = false;
|
|
160
|
-
let editParams: { channel_id: string | null; connection_id?: string | null } | undefined;
|
|
161
|
-
|
|
162
|
-
member.edit = async (params: {
|
|
163
|
-
channel_id: string | null;
|
|
164
|
-
connection_id?: string | null;
|
|
165
|
-
}) => {
|
|
166
|
-
editCalled = true;
|
|
167
|
-
editParams = params;
|
|
168
|
-
return member;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
await member.move(null);
|
|
172
|
-
|
|
173
|
-
expect(editCalled).toBe(true);
|
|
174
|
-
expect(editParams).toEqual({
|
|
175
|
-
channel_id: null,
|
|
176
|
-
connection_id: undefined,
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('calls edit with connection_id when provided', async () => {
|
|
181
|
-
const member = createMember();
|
|
182
|
-
let editCalled: boolean = false;
|
|
183
|
-
let editParams: { channel_id: string | null; connection_id?: string | null } | undefined;
|
|
184
|
-
|
|
185
|
-
member.edit = async (params: {
|
|
186
|
-
channel_id: string | null;
|
|
187
|
-
connection_id?: string | null;
|
|
188
|
-
}) => {
|
|
189
|
-
editCalled = true;
|
|
190
|
-
editParams = params;
|
|
191
|
-
return member;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
await member.move('voicechannel123', 'connection456');
|
|
195
|
-
|
|
196
|
-
expect(editCalled).toBe(true);
|
|
197
|
-
expect(editParams).toEqual({
|
|
198
|
-
channel_id: 'voicechannel123',
|
|
199
|
-
connection_id: 'connection456',
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
});
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { Client } from '../client/Client.js';
|
|
2
|
-
import { Base } from './Base.js';
|
|
3
|
-
import { User } from './User.js';
|
|
4
|
-
import { Guild } from './Guild.js';
|
|
5
|
-
import { GuildChannel } from './Channel.js';
|
|
6
|
-
import { APIGuildMember } from '@erinjs/types';
|
|
7
|
-
import { BitField, PermissionFlags } from '@erinjs/util';
|
|
8
|
-
import { Routes } from '@erinjs/types';
|
|
9
|
-
import { cdnMemberAvatarURL, cdnMemberBannerURL } from '../util/cdn.js';
|
|
10
|
-
import { computePermissions } from '../util/permissions.js';
|
|
11
|
-
import { GuildMemberRoleManager } from './GuildMemberRoleManager.js';
|
|
12
|
-
|
|
13
|
-
/** Represents a member of a guild. */
|
|
14
|
-
export class GuildMember extends Base {
|
|
15
|
-
readonly client: Client;
|
|
16
|
-
readonly id: string;
|
|
17
|
-
readonly user: User;
|
|
18
|
-
readonly guild: Guild;
|
|
19
|
-
nick: string | null;
|
|
20
|
-
/**
|
|
21
|
-
* Role manager with add/remove/set and cache. Discord.js parity: member.roles.add(), member.roles.cache
|
|
22
|
-
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
23
|
-
*/
|
|
24
|
-
readonly roles: GuildMemberRoleManager;
|
|
25
|
-
readonly joinedAt: Date;
|
|
26
|
-
communicationDisabledUntil: Date | null;
|
|
27
|
-
readonly mute: boolean;
|
|
28
|
-
readonly deaf: boolean;
|
|
29
|
-
readonly avatar: string | null;
|
|
30
|
-
readonly banner: string | null;
|
|
31
|
-
readonly accentColor: number | null;
|
|
32
|
-
readonly profileFlags: number | null;
|
|
33
|
-
|
|
34
|
-
/** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
|
|
35
|
-
constructor(client: Client, data: APIGuildMember & { guild_id?: string }, guild: Guild) {
|
|
36
|
-
super();
|
|
37
|
-
this.client = client;
|
|
38
|
-
this.user = client.getOrCreateUser(data.user);
|
|
39
|
-
this.id = data.user.id;
|
|
40
|
-
this.guild = guild;
|
|
41
|
-
this.nick = data.nick ?? null;
|
|
42
|
-
this.roles = new GuildMemberRoleManager(this, data.roles ?? []);
|
|
43
|
-
this.joinedAt = new Date(data.joined_at);
|
|
44
|
-
this.communicationDisabledUntil = data.communication_disabled_until
|
|
45
|
-
? new Date(data.communication_disabled_until)
|
|
46
|
-
: null;
|
|
47
|
-
this.mute = data.mute ?? false;
|
|
48
|
-
this.deaf = data.deaf ?? false;
|
|
49
|
-
this.avatar = data.avatar ?? null;
|
|
50
|
-
this.banner = data.banner ?? null;
|
|
51
|
-
this.accentColor = data.accent_color ?? null;
|
|
52
|
-
this.profileFlags = data.profile_flags ?? null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Nickname, or global name, or username. */
|
|
56
|
-
get displayName(): string {
|
|
57
|
-
return this.nick ?? this.user.globalName ?? this.user.username;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Get the guild-specific avatar URL for this member.
|
|
62
|
-
* Returns null if the member has no guild avatar (use displayAvatarURL for fallback).
|
|
63
|
-
*/
|
|
64
|
-
avatarURL(options?: { size?: number; extension?: string }): string | null {
|
|
65
|
-
return cdnMemberAvatarURL(this.guild.id, this.id, this.avatar, options);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get the avatar URL to display for this member.
|
|
70
|
-
* Uses guild-specific avatar if set, otherwise falls back to the user's avatar.
|
|
71
|
-
*/
|
|
72
|
-
displayAvatarURL(options?: { size?: number; extension?: string }): string {
|
|
73
|
-
return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get the guild-specific banner URL for this member.
|
|
78
|
-
* Returns null if the member has no guild banner.
|
|
79
|
-
*/
|
|
80
|
-
bannerURL(options?: { size?: number; extension?: string }): string | null {
|
|
81
|
-
return cdnMemberBannerURL(this.guild.id, this.id, this.banner, options);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Add a role to this member.
|
|
86
|
-
* Prefer member.roles.add(roleId) for Discord.js parity.
|
|
87
|
-
* @param roleId - The role ID to add
|
|
88
|
-
* Requires Manage Roles permission.
|
|
89
|
-
*/
|
|
90
|
-
async addRole(roleId: string): Promise<void> {
|
|
91
|
-
await this.roles.add(roleId);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Remove a role from this member.
|
|
96
|
-
* Prefer member.roles.remove(roleId) for Discord.js parity.
|
|
97
|
-
* @param roleId - The role ID to remove
|
|
98
|
-
* Requires Manage Roles permission.
|
|
99
|
-
*/
|
|
100
|
-
async removeRole(roleId: string): Promise<void> {
|
|
101
|
-
await this.roles.remove(roleId);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Edit this guild member. PATCH /guilds/{id}/members/{userId} or /members/@me for the bot.
|
|
106
|
-
* For @me: nick, avatar, banner, bio, pronouns, accent_color, profile_flags, mute, deaf,
|
|
107
|
-
* communication_disabled_until, timeout_reason, channel_id, connection_id.
|
|
108
|
-
* For other members: same plus roles (array of role IDs).
|
|
109
|
-
*/
|
|
110
|
-
async edit(options: {
|
|
111
|
-
nick?: string | null;
|
|
112
|
-
roles?: string[];
|
|
113
|
-
avatar?: string | null;
|
|
114
|
-
banner?: string | null;
|
|
115
|
-
bio?: string | null;
|
|
116
|
-
pronouns?: string | null;
|
|
117
|
-
accent_color?: number | null;
|
|
118
|
-
profile_flags?: number | null;
|
|
119
|
-
mute?: boolean;
|
|
120
|
-
deaf?: boolean;
|
|
121
|
-
communication_disabled_until?: string | null;
|
|
122
|
-
timeout_reason?: string | null;
|
|
123
|
-
channel_id?: string | null;
|
|
124
|
-
connection_id?: string | null;
|
|
125
|
-
}): Promise<this> {
|
|
126
|
-
const isMe = this.client.user?.id === this.id;
|
|
127
|
-
const route = isMe
|
|
128
|
-
? `/guilds/${this.guild.id}/members/@me`
|
|
129
|
-
: Routes.guildMember(this.guild.id, this.id);
|
|
130
|
-
const data = await this.client.rest.patch<APIGuildMember>(route, {
|
|
131
|
-
body: options,
|
|
132
|
-
auth: true,
|
|
133
|
-
});
|
|
134
|
-
this.nick = data.nick ?? this.nick;
|
|
135
|
-
if (data.roles) this.roles._patch(data.roles);
|
|
136
|
-
if (data.communication_disabled_until != null) {
|
|
137
|
-
(this as { communicationDisabledUntil: Date | null }).communicationDisabledUntil =
|
|
138
|
-
data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
139
|
-
}
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Get the member's guild-level permissions (from roles only, no channel overwrites).
|
|
145
|
-
* Use this for server-wide permission checks (e.g. ban, kick, manage roles).
|
|
146
|
-
* @returns Object with has(permission) to check specific permissions
|
|
147
|
-
* @example
|
|
148
|
-
* const perms = member.permissions;
|
|
149
|
-
* if (perms.has(PermissionFlags.BanMembers)) { ... }
|
|
150
|
-
*/
|
|
151
|
-
get permissions() {
|
|
152
|
-
const base = this._computeBasePermissions();
|
|
153
|
-
const ownerId = this.guild.ownerId;
|
|
154
|
-
const isOwner = ownerId != null && ownerId !== '' && String(ownerId) === String(this.id);
|
|
155
|
-
const perms = computePermissions(base, [], [], this.id, isOwner);
|
|
156
|
-
return new BitField<keyof typeof PermissionFlags>(perms);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Compute the member's effective permissions in a guild channel.
|
|
161
|
-
* Applies role permissions and channel overwrites.
|
|
162
|
-
* @param channel - The guild channel to check permissions for
|
|
163
|
-
* @returns Object with has(permission) to check specific permissions
|
|
164
|
-
* @example
|
|
165
|
-
* const perms = member.permissionsIn(channel);
|
|
166
|
-
* if (perms.has(PermissionFlags.SendMessages)) { ... }
|
|
167
|
-
*/
|
|
168
|
-
permissionsIn(channel: GuildChannel) {
|
|
169
|
-
const base = this._computeBasePermissions();
|
|
170
|
-
const ownerId = this.guild.ownerId;
|
|
171
|
-
const isOwner = ownerId != null && ownerId !== '' && String(ownerId) === String(this.id);
|
|
172
|
-
const perms = computePermissions(
|
|
173
|
-
base,
|
|
174
|
-
channel.permissionOverwrites,
|
|
175
|
-
[...this.roles.roleIds],
|
|
176
|
-
this.id,
|
|
177
|
-
isOwner,
|
|
178
|
-
);
|
|
179
|
-
return new BitField<keyof typeof PermissionFlags>(perms);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Move this member to a different voice channel or disconnect them from voice.
|
|
184
|
-
* Requires Move Members permission.
|
|
185
|
-
* @param channelId - The voice channel ID to move the member to, or null to disconnect
|
|
186
|
-
* @param connectionId - Optional connection ID for the specific voice session (usually not needed)
|
|
187
|
-
* @returns Promise that resolves when the member has been moved
|
|
188
|
-
* @example
|
|
189
|
-
* // Move member to a different voice channel
|
|
190
|
-
* await member.move('123456789012345678');
|
|
191
|
-
*
|
|
192
|
-
* // Disconnect member from voice
|
|
193
|
-
* await member.move(null);
|
|
194
|
-
*/
|
|
195
|
-
async move(channelId: string | null, connectionId?: string | null): Promise<void> {
|
|
196
|
-
await this.edit({
|
|
197
|
-
channel_id: channelId,
|
|
198
|
-
connection_id: connectionId,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
private _computeBasePermissions(): bigint {
|
|
203
|
-
let base = 0n;
|
|
204
|
-
const everyone = this.guild.roles.get(this.guild.id);
|
|
205
|
-
if (everyone) base |= everyone.permissions.bitfield;
|
|
206
|
-
for (const roleId of this.roles.roleIds) {
|
|
207
|
-
if (roleId === this.guild.id) continue;
|
|
208
|
-
const role = this.guild.roles.get(roleId);
|
|
209
|
-
if (role) base |= role.permissions.bitfield;
|
|
210
|
-
}
|
|
211
|
-
return base;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Collection } from '@erinjs/collection';
|
|
2
|
-
import { Routes } from '@erinjs/types';
|
|
3
|
-
import type { GuildMember } from './GuildMember.js';
|
|
4
|
-
import type { Role } from './Role.js';
|
|
5
|
-
|
|
6
|
-
/** Role ID or Role object for add/remove. */
|
|
7
|
-
export type RoleResolvable = string | Role;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Manages a guild member's roles with add/remove/set and a cache of Role objects.
|
|
11
|
-
* Discord.js parity: member.roles.add(), member.roles.remove(), member.roles.set(), member.roles.cache
|
|
12
|
-
*
|
|
13
|
-
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
14
|
-
* @example
|
|
15
|
-
* // Add a role (Discord.js style)
|
|
16
|
-
* await member.roles.add(roleId);
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Remove a role
|
|
20
|
-
* await member.roles.remove(roleId);
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Replace all roles
|
|
24
|
-
* await member.roles.set(['roleId1', 'roleId2']);
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Check if member has a role
|
|
28
|
-
* if (member.roles.cache.has(roleId)) { ... }
|
|
29
|
-
*/
|
|
30
|
-
export class GuildMemberRoleManager {
|
|
31
|
-
private _roleIds: string[] = [];
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
private readonly member: GuildMember,
|
|
35
|
-
initialRoleIds: string[] = [],
|
|
36
|
-
) {
|
|
37
|
-
this._roleIds = [...initialRoleIds];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Role IDs for this member. Used by permissions; prefer cache for Role objects. */
|
|
41
|
-
get roleIds(): readonly string[] {
|
|
42
|
-
return this._roleIds;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Check if the member has a role. Discord.js parity: member.roles.cache.has(roleId) */
|
|
46
|
-
has(roleOrId: RoleResolvable): boolean {
|
|
47
|
-
return this._roleIds.includes(this._resolveId(roleOrId));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Collection of Role objects for this member's roles (from guild.roles).
|
|
52
|
-
* Discord.js parity: member.roles.cache
|
|
53
|
-
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
54
|
-
*/
|
|
55
|
-
get cache(): Collection<string, Role> {
|
|
56
|
-
const coll = new Collection<string, Role>();
|
|
57
|
-
for (const id of this._roleIds) {
|
|
58
|
-
const role = this.member.guild.roles.get(id);
|
|
59
|
-
if (role) coll.set(id, role);
|
|
60
|
-
}
|
|
61
|
-
return coll;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Resolve role ID from RoleResolvable. */
|
|
65
|
-
private _resolveId(roleOrId: RoleResolvable): string {
|
|
66
|
-
return typeof roleOrId === 'string' ? roleOrId : roleOrId.id;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Add a role to this member.
|
|
71
|
-
* Discord.js parity: member.roles.add(roleId)
|
|
72
|
-
* Requires Manage Roles permission.
|
|
73
|
-
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
74
|
-
*/
|
|
75
|
-
async add(roleOrId: RoleResolvable): Promise<void> {
|
|
76
|
-
const roleId = this._resolveId(roleOrId);
|
|
77
|
-
if (this._roleIds.includes(roleId)) return;
|
|
78
|
-
await this.member.client.rest.put(
|
|
79
|
-
Routes.guildMemberRole(this.member.guild.id, this.member.id, roleId),
|
|
80
|
-
);
|
|
81
|
-
this._roleIds.push(roleId);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Remove a role from this member.
|
|
86
|
-
* Discord.js parity: member.roles.remove(roleId)
|
|
87
|
-
* Requires Manage Roles permission.
|
|
88
|
-
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
89
|
-
*/
|
|
90
|
-
async remove(roleOrId: RoleResolvable): Promise<void> {
|
|
91
|
-
const roleId = this._resolveId(roleOrId);
|
|
92
|
-
const idx = this._roleIds.indexOf(roleId);
|
|
93
|
-
if (idx === -1) return;
|
|
94
|
-
await this.member.client.rest.delete(
|
|
95
|
-
Routes.guildMemberRole(this.member.guild.id, this.member.id, roleId),
|
|
96
|
-
);
|
|
97
|
-
this._roleIds.splice(idx, 1);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Replace all roles for this member. PATCH /guilds/{id}/members/{userId}
|
|
102
|
-
* Discord.js parity: member.roles.set(roleIds)
|
|
103
|
-
* Requires Manage Roles permission.
|
|
104
|
-
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
105
|
-
*/
|
|
106
|
-
async set(roleIds: string[]): Promise<void> {
|
|
107
|
-
const data = await this.member.client.rest.patch<import('@erinjs/types').APIGuildMember>(
|
|
108
|
-
Routes.guildMember(this.member.guild.id, this.member.id),
|
|
109
|
-
{ body: { roles: roleIds }, auth: true },
|
|
110
|
-
);
|
|
111
|
-
this._roleIds = data.roles ? [...data.roles] : [];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Update internal role IDs from API response. Called by GuildMember.edit().
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
_patch(roleIds: string[]): void {
|
|
119
|
-
this._roleIds = [...roleIds];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Client } from '../client/Client.js';
|
|
2
|
-
import { Base } from './Base.js';
|
|
3
|
-
import { APISticker } from '@erinjs/types';
|
|
4
|
-
import { Routes } from '@erinjs/types';
|
|
5
|
-
import { CDN_URL } from '../util/Constants.js';
|
|
6
|
-
|
|
7
|
-
/** Represents a custom sticker in a guild. */
|
|
8
|
-
export class GuildSticker extends Base {
|
|
9
|
-
readonly client: Client;
|
|
10
|
-
readonly id: string;
|
|
11
|
-
readonly guildId: string;
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
readonly tags: string[];
|
|
15
|
-
readonly animated: boolean;
|
|
16
|
-
|
|
17
|
-
/** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
|
|
18
|
-
constructor(client: Client, data: APISticker & { guild_id?: string }, guildId: string) {
|
|
19
|
-
super();
|
|
20
|
-
this.client = client;
|
|
21
|
-
this.id = data.id;
|
|
22
|
-
this.guildId = data.guild_id ?? guildId;
|
|
23
|
-
this.name = data.name;
|
|
24
|
-
this.description = data.description ?? '';
|
|
25
|
-
this.tags = data.tags ?? [];
|
|
26
|
-
this.animated = data.animated ?? false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** CDN URL for this sticker image. */
|
|
30
|
-
get url(): string {
|
|
31
|
-
const ext = this.animated ? 'gif' : 'png';
|
|
32
|
-
return `${CDN_URL}/stickers/${this.id}.${ext}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
36
|
-
async delete(): Promise<void> {
|
|
37
|
-
await this.client.rest.delete(Routes.guildSticker(this.guildId, this.id), {
|
|
38
|
-
auth: true,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Edit this sticker's name and/or description.
|
|
44
|
-
* Requires Manage Emojis and Stickers permission.
|
|
45
|
-
*/
|
|
46
|
-
async edit(options: { name?: string; description?: string }): Promise<GuildSticker> {
|
|
47
|
-
const data = await this.client.rest.patch(Routes.guildSticker(this.guildId, this.id), {
|
|
48
|
-
body: options,
|
|
49
|
-
auth: true,
|
|
50
|
-
});
|
|
51
|
-
const s = data as APISticker;
|
|
52
|
-
this.name = s.name;
|
|
53
|
-
this.description = s.description ?? '';
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
}
|