@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,130 +0,0 @@
|
|
|
1
|
-
# Roles
|
|
2
|
-
|
|
3
|
-
Create, fetch, edit, and delete guild roles. Use PermissionFlags and resolvePermissionsToBitfield for permission bitfields.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Guild roles can be created, fetched, edited, and deleted. Use guild.createRole(), guild.fetchRoles(), guild.fetchRole(roleId), role.edit(), and role.delete(). Requires Manage Roles permission. For permission bitfields, use resolvePermissionsToBitfield() or role.has() to check a role's permissions.
|
|
8
|
-
|
|
9
|
-
## Create a role
|
|
10
|
-
|
|
11
|
-
Use guild.createRole() to create a new role. Pass name, permissions, color, hoist, mentionable, unicode_emoji, position, or hoist_position. Permissions accept PermissionResolvable (string, number, array) for convenience.
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import { Client, Events, PermissionFlags, resolvePermissionsToBitfield } from '@erinjs/core';
|
|
15
|
-
|
|
16
|
-
const client = new Client({ intents: 0 });
|
|
17
|
-
|
|
18
|
-
client.on(Events.MessageCreate, async (message) => {
|
|
19
|
-
if (message.content === '!createrole' && message.guildId) {
|
|
20
|
-
const guild = client.guilds.get(message.guildId) ?? await client.guilds.resolve(message.guildId);
|
|
21
|
-
if (!guild) return;
|
|
22
|
-
|
|
23
|
-
const role = await guild.createRole({
|
|
24
|
-
name: 'Moderator',
|
|
25
|
-
permissions: ['BanMembers', 'KickMembers', 'ManageMessages'],
|
|
26
|
-
color: 0x5865f2,
|
|
27
|
-
hoist: true,
|
|
28
|
-
mentionable: false,
|
|
29
|
-
});
|
|
30
|
-
await message.reply(`Created role ${role.name} (${role.id})`);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Fetch roles
|
|
38
|
-
|
|
39
|
-
Use guild.fetchRoles() to fetch all roles from the API and cache them. Use guild.fetchRole(roleId) to fetch a single role by ID. Throws ErinError with ROLE_NOT_FOUND on 404.
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
// Fetch all roles (updates guild.roles cache)
|
|
43
|
-
const roles = await guild.fetchRoles();
|
|
44
|
-
|
|
45
|
-
// Fetch a single role by ID
|
|
46
|
-
const role = await guild.fetchRole(roleId);
|
|
47
|
-
console.log(role.name, role.color);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Edit a role
|
|
51
|
-
|
|
52
|
-
Use role.edit() to update a role. Pass any of name, permissions, color, hoist, mentionable, unicode_emoji, position, hoist_position. Permissions accept PermissionResolvable.
|
|
53
|
-
|
|
54
|
-
```javascript
|
|
55
|
-
const role = guild.roles.get(roleId) ?? await guild.fetchRole(roleId);
|
|
56
|
-
await role.edit({
|
|
57
|
-
name: 'Senior Mod',
|
|
58
|
-
permissions: ['BanMembers', 'KickMembers', 'ManageMessages', 'ManageRoles'],
|
|
59
|
-
color: 0x57f287,
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Delete a role
|
|
64
|
-
|
|
65
|
-
Use role.delete() to remove a role. The role is removed from guild.roles cache.
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
const role = guild.roles.get(roleId) ?? await guild.fetchRole(roleId);
|
|
69
|
-
await role.delete();
|
|
70
|
-
await message.reply('Role deleted.');
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Check role permissions
|
|
74
|
-
|
|
75
|
-
Use role.has(permission) to check if a role has a specific permission. Administrator implies all permissions.
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
import { PermissionFlags } from '@erinjs/core';
|
|
79
|
-
|
|
80
|
-
if (role.has(PermissionFlags.BanMembers)) {
|
|
81
|
-
await message.reply('This role can ban members.');
|
|
82
|
-
}
|
|
83
|
-
if (role.has('ManageChannels')) {
|
|
84
|
-
await message.reply('This role can manage channels.');
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Add/remove roles from members (member.roles)
|
|
89
|
-
|
|
90
|
-
::: info Discord.js Compatible
|
|
91
|
-
See [API reference](/v/latest/api/classes/GuildMemberRoleManager) for full details.
|
|
92
|
-
:::
|
|
93
|
-
|
|
94
|
-
Use member.roles.add(), member.roles.remove(), and member.roles.set() for Discord.js-style role management. member.roles.cache is a Collection of Role objects. Also available: guild.addRoleToMember() and guild.removeRoleFromMember() when you only have user ID.
|
|
95
|
-
|
|
96
|
-
```javascript
|
|
97
|
-
// Discord.js parity: member.roles.add(), remove(), set()
|
|
98
|
-
const member = await guild.fetchMember(userId);
|
|
99
|
-
|
|
100
|
-
await member.roles.add(roleId); // Add a role
|
|
101
|
-
await member.roles.remove(roleId); // Remove a role
|
|
102
|
-
await member.roles.set(['id1', 'id2']); // Replace all roles
|
|
103
|
-
|
|
104
|
-
// Check if member has a role
|
|
105
|
-
if (member.roles.cache.has(roleId)) {
|
|
106
|
-
await message.reply('Member already has this role.');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Guild-level: when you only have user ID (no member fetch needed)
|
|
110
|
-
await guild.addRoleToMember(userId, roleId);
|
|
111
|
-
await guild.removeRoleFromMember(userId, roleId);
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Permission bitfields for create/edit
|
|
115
|
-
|
|
116
|
-
When creating or editing roles, pass permissions as a string (API format), number, PermissionString, or array. Use resolvePermissionsToBitfield() to combine multiple permissions. Handles high bits (PinMessages, ModerateMembers, etc.) correctly with BigInt.
|
|
117
|
-
|
|
118
|
-
```javascript
|
|
119
|
-
import { resolvePermissionsToBitfield, PermissionFlags } from '@erinjs/core';
|
|
120
|
-
|
|
121
|
-
// Single permission by name
|
|
122
|
-
resolvePermissionsToBitfield('SendMessages'); // "2048"
|
|
123
|
-
|
|
124
|
-
// Array of permissions (OR'd together)
|
|
125
|
-
resolvePermissionsToBitfield(['SendMessages', 'ViewChannel', 'ReadMessageHistory']);
|
|
126
|
-
// Returns combined bitfield as string
|
|
127
|
-
|
|
128
|
-
// From PermissionFlags enum
|
|
129
|
-
resolvePermissionsToBitfield(PermissionFlags.BanMembers); // "4"
|
|
130
|
-
```
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# Sending Without Reply
|
|
2
|
-
|
|
3
|
-
Send messages to the same channel or to specific channels. Covers message.send(), message.sendTo(), client.channels.send(), and client.channels.resolve().
|
|
4
|
-
|
|
5
|
-
## message.send() vs message.reply()
|
|
6
|
-
|
|
7
|
-
message.reply() sends a message that references another message (shows as a "reply" in Discord). message.send() sends to the same channel with no reference—a regular standalone message.
|
|
8
|
-
|
|
9
|
-
## Sending to the same channel
|
|
10
|
-
|
|
11
|
-
Use message.send() when you want to post in the channel without replying. Same signature as reply(): pass a string or object with content and/or embeds.
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import { Client, Events } from '@erinjs/core';
|
|
15
|
-
|
|
16
|
-
const client = new Client({ intents: 0 });
|
|
17
|
-
|
|
18
|
-
client.on(Events.MessageCreate, async (message) => {
|
|
19
|
-
if (message.content === '!hello') {
|
|
20
|
-
await message.send('Hello! This is a regular message, not a reply.');
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Sending to a specific channel (e.g. logging)
|
|
28
|
-
|
|
29
|
-
Use message.sendTo(channelId, payload) to send to another channel—handy for logging, announcements, or forwarding. You only need the target channel ID.
|
|
30
|
-
|
|
31
|
-
```javascript
|
|
32
|
-
import { Client, Events, EmbedBuilder } from '@erinjs/core';
|
|
33
|
-
|
|
34
|
-
const client = new Client({ intents: 0 });
|
|
35
|
-
const LOG_CHANNEL_ID = process.env.LOG_CHANNEL_ID; // Your log channel's snowflake
|
|
36
|
-
|
|
37
|
-
client.on(Events.MessageCreate, async (message) => {
|
|
38
|
-
if (message.content === '!report' && message.guildId && LOG_CHANNEL_ID) {
|
|
39
|
-
const embed = new EmbedBuilder()
|
|
40
|
-
.setTitle('User report')
|
|
41
|
-
.setDescription(message.content)
|
|
42
|
-
.addFields(
|
|
43
|
-
{ name: 'Author', value: message.author.username, inline: true },
|
|
44
|
-
{ name: 'Channel', value: `<#${message.channelId}>`, inline: true }
|
|
45
|
-
)
|
|
46
|
-
.setTimestamp();
|
|
47
|
-
|
|
48
|
-
await message.sendTo(LOG_CHANNEL_ID, { embeds: [embed] });
|
|
49
|
-
await message.send('Report logged.');
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## client.channels.send() — send by channel ID
|
|
57
|
-
|
|
58
|
-
Use client.channels.send(channelId, payload) when you have a channel ID. Works even if the channel is not cached. No need to fetch first when you only need to send.
|
|
59
|
-
|
|
60
|
-
```javascript
|
|
61
|
-
import { Client, Events } from '@erinjs/core';
|
|
62
|
-
|
|
63
|
-
const client = new Client({ intents: 0 });
|
|
64
|
-
const ANNOUNCE_CHANNEL_ID = process.env.ANNOUNCE_CHANNEL_ID;
|
|
65
|
-
|
|
66
|
-
client.on(Events.Ready, async () => {
|
|
67
|
-
if (ANNOUNCE_CHANNEL_ID) {
|
|
68
|
-
await client.channels.send(ANNOUNCE_CHANNEL_ID, 'Bot is online!');
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## client.channels.resolve() — get channel by ID
|
|
76
|
-
|
|
77
|
-
Resolve a channel by ID from cache or API. Use channel.canSendMessage() or channel.isTextBased() before sending. For sending when you only have an ID, prefer client.channels.send() which skips the fetch.
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
import { Client } from '@erinjs/core';
|
|
81
|
-
|
|
82
|
-
const client = new Client({ intents: 0 });
|
|
83
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
84
|
-
|
|
85
|
-
// Fetch channel (from API if not cached)
|
|
86
|
-
const channel = await client.channels.resolve(channelId);
|
|
87
|
-
if (channel?.canSendMessage()) {
|
|
88
|
-
await channel.send('Hello!');
|
|
89
|
-
}
|
|
90
|
-
// Or for webhooks: if (channel?.createWebhook) { ... }
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## fetch message by id
|
|
94
|
-
|
|
95
|
-
Use channel.messages.fetch(messageId) when you have the channel. For IDs-only, fetch the channel first.
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
// When you have the channel
|
|
99
|
-
const message = await channel.messages.fetch(messageId);
|
|
100
|
-
if (message) {
|
|
101
|
-
await message.edit({ content: 'Updated!' });
|
|
102
|
-
await message.react('👍');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// When you only have IDs (e.g. from sqlite)
|
|
106
|
-
const ch = await client.channels.resolve(channelId);
|
|
107
|
-
const msg = await ch?.messages?.fetch(messageId);
|
|
108
|
-
if (msg) await msg.delete();
|
|
109
|
-
|
|
110
|
-
// When channel is cached
|
|
111
|
-
const m = client.channels.get(channelId);
|
|
112
|
-
if (m?.canSendMessage()) {
|
|
113
|
-
const mes = await m.messages.fetch(messageId);
|
|
114
|
-
if (mes) await mes.edit({ content: 'Edited!' });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Refresh a stale message instance
|
|
118
|
-
const updated = await message.fetch();
|
|
119
|
-
if (updated) console.log(updated.content);
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## message.channel and message.channel.send()
|
|
123
|
-
|
|
124
|
-
message.channel returns the channel (from cache); null if not cached. Messages only exist in text-based channels, so when non-null it always has send(). Use message.channel.send() for the same as message.send() but via the channel object.
|
|
125
|
-
|
|
126
|
-
```javascript
|
|
127
|
-
client.on(Events.MessageCreate, async (message) => {
|
|
128
|
-
const channel = message.channel; // TextChannel | DMChannel | GuildChannel | null
|
|
129
|
-
const guild = message.guild; // Guild | null (null for DMs)
|
|
130
|
-
if (channel) {
|
|
131
|
-
await channel.send('Same channel, different API'); // or message.send()
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## channel.canSendMessage() — permission check
|
|
137
|
-
|
|
138
|
-
Before sending, use canSendMessage() to check if the bot has ViewChannel and SendMessages. For DMs always true; for guild channels uses guild.members.me permissions.
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
const channel = await client.channels.resolve(channelId);
|
|
142
|
-
if (channel?.canSendMessage()) {
|
|
143
|
-
await channel.send('Hello!');
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Typing indicator
|
|
148
|
-
|
|
149
|
-
Use channel.sendTyping() before a slow operation so users see "Bot is typing...". Lasts ~10 seconds.
|
|
150
|
-
|
|
151
|
-
```javascript
|
|
152
|
-
const channel = message.channel ?? (await message.resolveChannel());
|
|
153
|
-
if (channel?.canSendMessage?.()) {
|
|
154
|
-
await channel.sendTyping();
|
|
155
|
-
await slowOperation(); // e.g. fetch external API
|
|
156
|
-
await message.reply('Done!');
|
|
157
|
-
}
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Quick reference
|
|
161
|
-
|
|
162
|
-
```javascript
|
|
163
|
-
// Same channel, no reply
|
|
164
|
-
await message.send('Pong!');
|
|
165
|
-
|
|
166
|
-
// Reply to the message
|
|
167
|
-
await message.reply('Pong!');
|
|
168
|
-
|
|
169
|
-
// Send to a specific channel
|
|
170
|
-
await message.sendTo(logChannelId, 'User joined!');
|
|
171
|
-
await client.channels.send(channelId, 'New update available!');
|
|
172
|
-
```
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# Voice
|
|
2
|
-
|
|
3
|
-
Join voice channels and play audio with @erinjs/voice. Supports WebM/Opus streams—no FFmpeg required.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Add the voice package alongside the core library.
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pnpm add @erinjs/voice @erinjs/core
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Setup
|
|
14
|
-
|
|
15
|
-
Create a VoiceManager before login so it receives VoiceStatesSync from READY/GUILD_CREATE. This lets the manager see users already in voice when the bot starts.
|
|
16
|
-
|
|
17
|
-
```javascript
|
|
18
|
-
import { Client, Events, VoiceChannel } from '@erinjs/core';
|
|
19
|
-
import { getVoiceManager } from '@erinjs/voice';
|
|
20
|
-
|
|
21
|
-
const client = new Client({ intents: 0 });
|
|
22
|
-
getVoiceManager(client); // Must be before login
|
|
23
|
-
|
|
24
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Join a Voice Channel
|
|
28
|
-
|
|
29
|
-
Get the user's voice channel with getVoiceChannelId, then join. The connection resolves when ready.
|
|
30
|
-
|
|
31
|
-
```javascript
|
|
32
|
-
const voiceManager = getVoiceManager(client);
|
|
33
|
-
const voiceChannelId = voiceManager.getVoiceChannelId(guildId, userId);
|
|
34
|
-
if (!voiceChannelId) return; // User not in voice
|
|
35
|
-
|
|
36
|
-
const channel = client.channels.get(voiceChannelId);
|
|
37
|
-
if (!(channel instanceof VoiceChannel)) return;
|
|
38
|
-
|
|
39
|
-
const connection = await voiceManager.join(channel);
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Play Audio
|
|
43
|
-
|
|
44
|
-
Play a WebM/Opus URL or stream. The voice package does not use FFmpeg—input must be WebM with Opus. Use yt-dlp or similar to get direct stream URLs from YouTube.
|
|
45
|
-
|
|
46
|
-
```javascript
|
|
47
|
-
// URL (fetched and demuxed automatically)
|
|
48
|
-
await connection.play('https://example.com/audio.webm');
|
|
49
|
-
|
|
50
|
-
// Or a Node.js ReadableStream of Opus
|
|
51
|
-
await connection.play(opusStream);
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Getting Stream URLs from YouTube
|
|
55
|
-
|
|
56
|
-
Use youtube-dl-exec or yt-dlp to extract a WebM/Opus URL.
|
|
57
|
-
|
|
58
|
-
```javascript
|
|
59
|
-
import youtubedl from 'youtube-dl-exec';
|
|
60
|
-
|
|
61
|
-
const result = await youtubedl(videoUrl, {
|
|
62
|
-
getUrl: true,
|
|
63
|
-
f: 'bestaudio[ext=webm][acodec=opus]/bestaudio[ext=webm]/bestaudio',
|
|
64
|
-
}, { timeout: 15000 });
|
|
65
|
-
|
|
66
|
-
const streamUrl = String(result ?? '').trim();
|
|
67
|
-
await connection.play(streamUrl);
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Volume Control
|
|
71
|
-
|
|
72
|
-
LiveKitRtcConnection supports setVolume(0-200) and getVolume(). 100 = normal, 50 = half, 200 = double. Affects current and future playback.
|
|
73
|
-
|
|
74
|
-
```javascript
|
|
75
|
-
import { LiveKitRtcConnection } from '@erinjs/voice';
|
|
76
|
-
|
|
77
|
-
if (connection instanceof LiveKitRtcConnection) {
|
|
78
|
-
connection.setVolume(80); // 80% volume
|
|
79
|
-
console.log('Current volume:', connection.getVolume());
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Stop and Leave
|
|
84
|
-
|
|
85
|
-
Stop playback and disconnect. getConnection accepts channel ID or guild ID. leave(guildId) leaves all channels; leaveChannel(channelId) leaves a specific channel.
|
|
86
|
-
|
|
87
|
-
```javascript
|
|
88
|
-
// By channel ID (primary) or guild ID
|
|
89
|
-
const connection = voiceManager.getConnection(channelId) ?? voiceManager.getConnection(guildId);
|
|
90
|
-
connection?.stop();
|
|
91
|
-
if (connection) voiceManager.leaveChannel(connection.channel.id);
|
|
92
|
-
// Or leave all channels in the guild:
|
|
93
|
-
voiceManager.leave(guildId);
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## LiveKit and serverLeave
|
|
97
|
-
|
|
98
|
-
If using LiveKit, the server may emit serverLeave. Listen and reconnect if needed.
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
connection.on?.('serverLeave', async () => {
|
|
102
|
-
try {
|
|
103
|
-
const conn = await voiceManager.join(channel);
|
|
104
|
-
await conn.play(streamUrl);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
console.error('Auto-reconnect failed:', e);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
```
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Wait for All Guilds
|
|
2
|
-
|
|
3
|
-
Delay the Ready event until all guilds have been received. Use when your bot needs the full guild cache before handling Ready.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
By default, Ready fires as soon as the gateway sends the READY payload. Some guilds may be sent as unavailable stubs and arrive later via GUILD_CREATE. Enable waitForGuilds if your Ready handler needs every guild to be in client.guilds before proceeding.
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
Pass waitForGuilds: true in ClientOptions. Ready will emit only after all guilds from READY (including those marked unavailable) have been received via GUILD_CREATE.
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import { Client, Events } from '@erinjs/core';
|
|
15
|
-
|
|
16
|
-
const client = new Client({
|
|
17
|
-
waitForGuilds: true,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
client.on(Events.Ready, () => {
|
|
21
|
-
// client.guilds now contains every guild — no stubs, all fully loaded
|
|
22
|
-
console.log(`Bot is in ${client.guilds.size} guilds`);
|
|
23
|
-
for (const [id, guild] of client.guilds) {
|
|
24
|
-
console.log(`- ${guild.name} (${guild.channels.size} channels)`);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## When to use it
|
|
32
|
-
|
|
33
|
-
Use waitForGuilds when your bot iterates over all guilds in Ready (e.g. syncing state, broadcasting announcements, or building in-memory caches). Without it, client.guilds may be incomplete at Ready time.
|
|
34
|
-
|
|
35
|
-
::: tip
|
|
36
|
-
If you only need a few guilds by ID, prefer client.guilds.resolve(guildId) instead — no need to wait for all guilds.
|
|
37
|
-
:::
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Webhook Attachments & Embeds
|
|
2
|
-
|
|
3
|
-
Send embeds with or without a title, and attach files to webhook messages—same API as channel messages.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Webhooks support rich embeds and file attachments. Embeds can have just a description (no title required), and you can attach files the same way as with channel.send or message.reply.
|
|
8
|
-
|
|
9
|
-
## Embeds Without a Title
|
|
10
|
-
|
|
11
|
-
You do not need a title for embeds to work. At least one of title, description, fields, or image/thumbnail is required. A description-only embed is valid.
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import { Client, Webhook, EmbedBuilder } from '@erinjs/core';
|
|
15
|
-
|
|
16
|
-
const client = new Client({ intents: 0 });
|
|
17
|
-
const webhook = Webhook.fromToken(client, webhookId, webhookToken);
|
|
18
|
-
|
|
19
|
-
// Description only—no title
|
|
20
|
-
await webhook.send({
|
|
21
|
-
embeds: [
|
|
22
|
-
new EmbedBuilder()
|
|
23
|
-
.setDescription('This embed has no title. Description-only works fine.')
|
|
24
|
-
.setColor(0x5865f2)
|
|
25
|
-
.setTimestamp(),
|
|
26
|
-
],
|
|
27
|
-
});
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Direct Attachments
|
|
31
|
-
|
|
32
|
-
Attach files to webhook messages using the files array. Each file needs name and data (Blob, ArrayBuffer, or Uint8Array). Optional filename overrides the display name.
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
import { Client, Webhook } from '@erinjs/core';
|
|
36
|
-
import { readFileSync } from 'fs';
|
|
37
|
-
|
|
38
|
-
const client = new Client({ intents: 0 });
|
|
39
|
-
const webhook = Webhook.fromToken(client, webhookId, webhookToken);
|
|
40
|
-
|
|
41
|
-
const buffer = readFileSync('report.pdf');
|
|
42
|
-
await webhook.send({
|
|
43
|
-
content: 'Report attached',
|
|
44
|
-
files: [
|
|
45
|
-
{ name: 'report.pdf', data: buffer },
|
|
46
|
-
{ name: 'log.txt', data: new TextEncoder().encode('Log content'), filename: 'log-2025.txt' },
|
|
47
|
-
],
|
|
48
|
-
});
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Full Example: Embed + Files
|
|
52
|
-
|
|
53
|
-
Combine content, description-only embed, and file attachments in a single webhook send.
|
|
54
|
-
|
|
55
|
-
```javascript
|
|
56
|
-
import { Client, Webhook, EmbedBuilder } from '@erinjs/core';
|
|
57
|
-
import { readFileSync } from 'fs';
|
|
58
|
-
|
|
59
|
-
const client = new Client({ intents: 0 });
|
|
60
|
-
const webhook = Webhook.fromToken(client, webhookId, webhookToken);
|
|
61
|
-
|
|
62
|
-
await webhook.send({
|
|
63
|
-
content: 'Build completed',
|
|
64
|
-
embeds: [
|
|
65
|
-
new EmbedBuilder()
|
|
66
|
-
.setDescription('Deploy succeeded. See attachment for logs.')
|
|
67
|
-
.setColor(0x57f287)
|
|
68
|
-
.setTimestamp(),
|
|
69
|
-
],
|
|
70
|
-
files: [{ name: 'deploy.log', data: readFileSync('deploy.log') }],
|
|
71
|
-
username: 'CI Bot',
|
|
72
|
-
});
|
|
73
|
-
```
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Webhooks
|
|
2
|
-
|
|
3
|
-
A complete guide to Discord webhooks—sending messages without a gateway, creating, editing, and managing webhooks.
|
|
4
|
-
|
|
5
|
-
## What are Webhooks?
|
|
6
|
-
|
|
7
|
-
Webhooks let you send messages to a channel using a URL (ID + token). You can use them in scripts, CI pipelines, or anywhere you need to post without a full bot connection. No gateway, no events—just REST.
|
|
8
|
-
|
|
9
|
-
## Webhooks Without a Bot
|
|
10
|
-
|
|
11
|
-
A Client with intents: 0 is enough. No need to connect to the gateway or handle events. Ideal for scripts or one-off sends.
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import { Client, Webhook } from '@erinjs/core';
|
|
15
|
-
|
|
16
|
-
const client = new Client({ intents: 0 });
|
|
17
|
-
const webhook = Webhook.fromToken(client, webhookId, webhookToken);
|
|
18
|
-
await webhook.send('Message from a script!');
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Creating a Webhook
|
|
22
|
-
|
|
23
|
-
Create a webhook on a text channel. Requires Manage Webhooks permission. The token is returned only when creating—store it securely. It will never be returned when listing or fetching.
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
import { Client } from '@erinjs/core';
|
|
27
|
-
|
|
28
|
-
const client = new Client({ intents: 0 });
|
|
29
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
30
|
-
|
|
31
|
-
const channel = client.channels.get(channelId);
|
|
32
|
-
if (!channel?.createWebhook) throw new Error('Channel does not support webhooks');
|
|
33
|
-
|
|
34
|
-
const webhook = await channel.createWebhook({ name: 'My Webhook' });
|
|
35
|
-
console.log(webhook.id, webhook.token); // Store token—it won't be returned when listing
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Sending Messages
|
|
39
|
-
|
|
40
|
-
Send text, embeds, or both. You can override the username and avatar for each message.
|
|
41
|
-
|
|
42
|
-
```javascript
|
|
43
|
-
import { Client, Webhook, EmbedBuilder } from '@erinjs/core';
|
|
44
|
-
|
|
45
|
-
const client = new Client({ intents: 0 });
|
|
46
|
-
const webhook = Webhook.fromToken(client, webhookId, webhookToken);
|
|
47
|
-
|
|
48
|
-
await webhook.send({
|
|
49
|
-
content: 'Hello from webhook!',
|
|
50
|
-
embeds: [
|
|
51
|
-
new EmbedBuilder()
|
|
52
|
-
.setTitle('Webhook Message')
|
|
53
|
-
.setColor(0x5865f2)
|
|
54
|
-
.setTimestamp(),
|
|
55
|
-
],
|
|
56
|
-
username: 'Custom Name',
|
|
57
|
-
avatar_url: 'https://example.com/avatar.png',
|
|
58
|
-
});
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Simple text only
|
|
62
|
-
|
|
63
|
-
```javascript
|
|
64
|
-
await webhook.send('Plain text message');
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Embeds without a title
|
|
68
|
-
|
|
69
|
-
Embeds can use only a description—no title required. At least one of title, description, fields, or image is needed.
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
await webhook.send({
|
|
73
|
-
embeds: [
|
|
74
|
-
new EmbedBuilder()
|
|
75
|
-
.setDescription('Description-only embed works.')
|
|
76
|
-
.setColor(0x5865f2),
|
|
77
|
-
],
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Fetching & Listing Webhooks
|
|
82
|
-
|
|
83
|
-
Fetch by ID or list channel/guild webhooks. Requires a logged-in bot. Fetched webhooks have no token and cannot send—but you can edit or delete them with bot auth.
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
import { Client, Webhook } from '@erinjs/core';
|
|
87
|
-
|
|
88
|
-
const client = new Client({ intents: 0 });
|
|
89
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
90
|
-
|
|
91
|
-
// Fetch single webhook (no token)
|
|
92
|
-
const webhook = await Webhook.fetch(client, webhookId);
|
|
93
|
-
|
|
94
|
-
// List channel webhooks
|
|
95
|
-
const channel = client.channels.get(channelId);
|
|
96
|
-
const channelWebhooks = await channel?.fetchWebhooks() ?? [];
|
|
97
|
-
|
|
98
|
-
// List guild webhooks
|
|
99
|
-
const guild = client.guilds.get(guildId);
|
|
100
|
-
const guildWebhooks = await guild?.fetchWebhooks() ?? [];
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Editing a Webhook
|
|
104
|
-
|
|
105
|
-
Use webhook.edit() to change name, avatar, or (with bot auth) channel. With a token (e.g. from createWebhook or fromToken), you can update name and avatar. Without a token (fetched webhook), bot auth lets you also change the target channel.
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
import { Client, Webhook } from '@erinjs/core';
|
|
109
|
-
|
|
110
|
-
const client = new Client({ intents: 0 });
|
|
111
|
-
await client.login(process.env.ERIN_BOT_TOKEN);
|
|
112
|
-
|
|
113
|
-
// With token (name and avatar only)
|
|
114
|
-
const webhook = Webhook.fromToken(client, webhookId, webhookToken);
|
|
115
|
-
await webhook.edit({ name: 'New Name', avatar: null });
|
|
116
|
-
// avatar: null clears the webhook avatar
|
|
117
|
-
|
|
118
|
-
// With bot auth (fetched webhook — can also move to another channel)
|
|
119
|
-
const fetched = await Webhook.fetch(client, webhookId);
|
|
120
|
-
await fetched.edit({
|
|
121
|
-
name: 'Updated Name',
|
|
122
|
-
channel_id: newChannelId, // move webhook to different channel
|
|
123
|
-
});
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Deleting a Webhook
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
const webhook = await Webhook.fetch(client, webhookId);
|
|
130
|
-
await webhook.delete();
|
|
131
|
-
```
|