@erinjs/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/.changeset/README.md +8 -0
- package/core/.changeset/community-bootstrap-release.md +17 -0
- package/core/.changeset/config.json +11 -0
- package/core/.changeset/no-changelog.js +16 -0
- package/core/.changeset/pre.json +17 -0
- package/core/.editorconfig +13 -0
- package/core/.gitattributes +2 -0
- package/core/.github/CODE_OF_CONDUCT.md +23 -0
- package/core/.github/FUNDING.yml +7 -0
- package/core/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
- package/core/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- package/core/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- package/core/.github/dependabot.yml +16 -0
- package/core/.github/workflows/autoapp.yml +16 -0
- package/core/.github/workflows/ci.yml +187 -0
- package/core/.github/workflows/codeql.yml +30 -0
- package/core/.github/workflows/deploy-docs.yml +54 -0
- package/core/.github/workflows/publish.yml +43 -0
- package/core/.lintstagedrc.json +4 -0
- package/core/.nvmrc +1 -0
- package/core/.prettierignore +8 -0
- package/core/.prettierrc +11 -0
- package/core/CONTRIBUTING.md +70 -0
- package/core/LICENSE +203 -0
- package/core/README.md +61 -0
- package/core/SECURITY.md +21 -0
- package/core/apps/docs/index.html +28 -0
- package/core/apps/docs/middleware.ts +21 -0
- package/core/apps/docs/package.json +33 -0
- package/core/apps/docs/public/@flux.png +0 -0
- package/core/apps/docs/public/docs/latest/guides.json +1420 -0
- package/core/apps/docs/public/docs/latest/main.json +14981 -0
- package/core/apps/docs/public/docs/latest/rag-index.json +1 -0
- package/core/apps/docs/public/docs/v1.0.5/guides.json +226 -0
- package/core/apps/docs/public/docs/v1.0.5/main.json +7920 -0
- package/core/apps/docs/public/docs/v1.0.6/guides.json +226 -0
- package/core/apps/docs/public/docs/v1.0.6/main.json +7920 -0
- package/core/apps/docs/public/docs/v1.0.7/guides.json +259 -0
- package/core/apps/docs/public/docs/v1.0.7/main.json +8652 -0
- package/core/apps/docs/public/docs/v1.0.8/guides.json +313 -0
- package/core/apps/docs/public/docs/v1.0.8/main.json +9618 -0
- package/core/apps/docs/public/docs/v1.0.9/guides.json +319 -0
- package/core/apps/docs/public/docs/v1.0.9/main.json +10694 -0
- package/core/apps/docs/public/docs/v1.1.0/guides.json +589 -0
- package/core/apps/docs/public/docs/v1.1.0/main.json +12576 -0
- package/core/apps/docs/public/docs/v1.1.2/guides.json +650 -0
- package/core/apps/docs/public/docs/v1.1.2/main.json +13239 -0
- package/core/apps/docs/public/docs/v1.1.3/guides.json +650 -0
- package/core/apps/docs/public/docs/v1.1.3/main.json +13239 -0
- package/core/apps/docs/public/docs/v1.1.4/guides.json +708 -0
- package/core/apps/docs/public/docs/v1.1.4/main.json +13231 -0
- package/core/apps/docs/public/docs/v1.1.5/guides.json +1035 -0
- package/core/apps/docs/public/docs/v1.1.5/main.json +13838 -0
- package/core/apps/docs/public/docs/v1.1.6/guides.json +1041 -0
- package/core/apps/docs/public/docs/v1.1.6/main.json +14313 -0
- package/core/apps/docs/public/docs/v1.1.8/guides.json +1047 -0
- package/core/apps/docs/public/docs/v1.1.8/main.json +14421 -0
- package/core/apps/docs/public/docs/v1.1.9/guides.json +1047 -0
- package/core/apps/docs/public/docs/v1.1.9/main.json +14421 -0
- package/core/apps/docs/public/docs/v1.2.0/guides.json +1212 -0
- package/core/apps/docs/public/docs/v1.2.0/main.json +14663 -0
- package/core/apps/docs/public/docs/v1.2.1/guides.json +1293 -0
- package/core/apps/docs/public/docs/v1.2.1/main.json +14828 -0
- package/core/apps/docs/public/docs/v1.2.2/guides.json +1293 -0
- package/core/apps/docs/public/docs/v1.2.2/main.json +15025 -0
- package/core/apps/docs/public/docs/v1.2.3/guides.json +1420 -0
- package/core/apps/docs/public/docs/v1.2.3/main.json +14954 -0
- package/core/apps/docs/public/docs/v1.2.4/guides.json +1420 -0
- package/core/apps/docs/public/docs/v1.2.4/main.json +14981 -0
- package/core/apps/docs/public/docs/versions.json +24 -0
- package/core/apps/docs/public/flux.png +0 -0
- package/core/apps/docs/public/locales/en.json +50 -0
- package/core/apps/docs/public/locales/guides-en.json +512 -0
- package/core/apps/docs/public/robots.txt +4 -0
- package/core/apps/docs/public/sitemap.xml +33 -0
- package/core/apps/docs/src/App.vue +538 -0
- package/core/apps/docs/src/components/ApiCategorySection.vue +42 -0
- package/core/apps/docs/src/components/ApiDiscordCompat.vue +65 -0
- package/core/apps/docs/src/components/ApiEndpointCard.vue +313 -0
- package/core/apps/docs/src/components/ApiSchemaBlock.vue +131 -0
- package/core/apps/docs/src/components/CodeBlock.vue +177 -0
- package/core/apps/docs/src/components/CommunityCallout.vue +90 -0
- package/core/apps/docs/src/components/ConstructorSection.vue +82 -0
- package/core/apps/docs/src/components/DocDescription.vue +40 -0
- package/core/apps/docs/src/components/FluxerLogo.vue +3 -0
- package/core/apps/docs/src/components/Footer.vue +106 -0
- package/core/apps/docs/src/components/GuideCodeBlock.vue +102 -0
- package/core/apps/docs/src/components/GuideDiscordCompat.vue +77 -0
- package/core/apps/docs/src/components/GuideDiscordCompatCallout.vue +83 -0
- package/core/apps/docs/src/components/GuideTable.vue +77 -0
- package/core/apps/docs/src/components/GuideTip.vue +38 -0
- package/core/apps/docs/src/components/MethodsSection.vue +195 -0
- package/core/apps/docs/src/components/ParamsTable.vue +70 -0
- package/core/apps/docs/src/components/PropertiesSection.vue +143 -0
- package/core/apps/docs/src/components/SearchBar.vue +76 -0
- package/core/apps/docs/src/components/SearchModal.vue +361 -0
- package/core/apps/docs/src/components/SidebarNav.vue +225 -0
- package/core/apps/docs/src/components/SponsorBanner.vue +153 -0
- package/core/apps/docs/src/components/TypeSignature.vue +187 -0
- package/core/apps/docs/src/components/VersionPicker.vue +191 -0
- package/core/apps/docs/src/composables/useSearchIndex.ts +144 -0
- package/core/apps/docs/src/composables/useVersionedPath.ts +20 -0
- package/core/apps/docs/src/data/apiEndpoints.ts +1073 -0
- package/core/apps/docs/src/data/changelog.ts +717 -0
- package/core/apps/docs/src/data/guides.ts +2362 -0
- package/core/apps/docs/src/env.d.ts +7 -0
- package/core/apps/docs/src/locales/guides-en.json +512 -0
- package/core/apps/docs/src/main.ts +27 -0
- package/core/apps/docs/src/pages/ApiReferenceLayout.vue +175 -0
- package/core/apps/docs/src/pages/ApiReferencePage.vue +128 -0
- package/core/apps/docs/src/pages/Changelog.vue +288 -0
- package/core/apps/docs/src/pages/ClassPage.vue +319 -0
- package/core/apps/docs/src/pages/ClassesList.vue +100 -0
- package/core/apps/docs/src/pages/DocsLayout.vue +127 -0
- package/core/apps/docs/src/pages/GuidePage.vue +279 -0
- package/core/apps/docs/src/pages/GuidesIndex.vue +166 -0
- package/core/apps/docs/src/pages/GuidesLayout.vue +245 -0
- package/core/apps/docs/src/pages/Home.vue +125 -0
- package/core/apps/docs/src/pages/NotFound.vue +57 -0
- package/core/apps/docs/src/pages/TypedefPage.vue +230 -0
- package/core/apps/docs/src/pages/TypedefsList.vue +168 -0
- package/core/apps/docs/src/pages/VersionLayout.vue +15 -0
- package/core/apps/docs/src/router.ts +73 -0
- package/core/apps/docs/src/stores/docs.ts +54 -0
- package/core/apps/docs/src/stores/guides.ts +53 -0
- package/core/apps/docs/src/stores/version.ts +67 -0
- package/core/apps/docs/src/styles/main.css +278 -0
- package/core/apps/docs/src/styles/prism.css +95 -0
- package/core/apps/docs/src/types/doc-schema.ts +112 -0
- package/core/apps/docs/tsconfig.json +17 -0
- package/core/apps/docs/tsconfig.node.json +10 -0
- package/core/apps/docs/vite.config.d.ts +2 -0
- package/core/apps/docs/vite.config.js +26 -0
- package/core/apps/docs/vite.config.ts +28 -0
- package/core/apps/docs-vitepress/.vitepress/config.ts +141 -0
- package/core/apps/docs-vitepress/api-data/latest/main.json +15035 -0
- package/core/apps/docs-vitepress/api-data/v1.2.4/main.json +15035 -0
- package/core/apps/docs-vitepress/api-data/versions.json +6 -0
- package/core/apps/docs-vitepress/index.md +15 -0
- package/core/apps/docs-vitepress/package-lock.json +2924 -0
- package/core/apps/docs-vitepress/package.json +20 -0
- package/core/apps/docs-vitepress/public/CNAME +1 -0
- package/core/apps/docs-vitepress/scripts/generate-api.ts +243 -0
- package/core/apps/docs-vitepress/scripts/migrate-guides.ts +129 -0
- package/core/apps/docs-vitepress/tsconfig.json +11 -0
- package/core/apps/docs-vitepress/v/latest/guides/attachments-by-url.md +57 -0
- package/core/apps/docs-vitepress/v/latest/guides/attachments.md +62 -0
- package/core/apps/docs-vitepress/v/latest/guides/basic-bot.md +49 -0
- package/core/apps/docs-vitepress/v/latest/guides/channels.md +180 -0
- package/core/apps/docs-vitepress/v/latest/guides/deprecated-apis.md +58 -0
- package/core/apps/docs-vitepress/v/latest/guides/discord-js-compatibility.md +42 -0
- package/core/apps/docs-vitepress/v/latest/guides/editing-embeds.md +65 -0
- package/core/apps/docs-vitepress/v/latest/guides/embed-media.md +87 -0
- package/core/apps/docs-vitepress/v/latest/guides/embeds.md +166 -0
- package/core/apps/docs-vitepress/v/latest/guides/emojis.md +77 -0
- package/core/apps/docs-vitepress/v/latest/guides/events.md +202 -0
- package/core/apps/docs-vitepress/v/latest/guides/gifs.md +47 -0
- package/core/apps/docs-vitepress/v/latest/guides/installation.md +10 -0
- package/core/apps/docs-vitepress/v/latest/guides/moderation.md +89 -0
- package/core/apps/docs-vitepress/v/latest/guides/permissions.md +130 -0
- package/core/apps/docs-vitepress/v/latest/guides/prefix-commands.md +41 -0
- package/core/apps/docs-vitepress/v/latest/guides/profile-urls.md +58 -0
- package/core/apps/docs-vitepress/v/latest/guides/reactions.md +69 -0
- package/core/apps/docs-vitepress/v/latest/guides/roles.md +130 -0
- package/core/apps/docs-vitepress/v/latest/guides/sending-without-reply.md +172 -0
- package/core/apps/docs-vitepress/v/latest/guides/voice.md +109 -0
- package/core/apps/docs-vitepress/v/latest/guides/wait-for-guilds.md +37 -0
- package/core/apps/docs-vitepress/v/latest/guides/webhook-attachments-embeds.md +73 -0
- package/core/apps/docs-vitepress/v/latest/guides/webhooks.md +131 -0
- package/core/eslint.config.js +80 -0
- package/core/examples/.env.example +22 -0
- package/core/examples/README.md +68 -0
- package/core/examples/first-steps-bot.js +118 -0
- package/core/examples/minimal-bot.js +17 -0
- package/core/examples/moderation-bot.js +209 -0
- package/core/examples/package.json +14 -0
- package/core/examples/ping-bot.js +1146 -0
- package/core/examples/reaction-bot.js +70 -0
- package/core/examples/reaction-roles-bot.js +140 -0
- package/core/examples/webhook-bot.js +239 -0
- package/core/flux.png +0 -0
- package/core/package.json +78 -0
- package/core/packages/builders/package.json +51 -0
- package/core/packages/builders/src/index.ts +13 -0
- package/core/packages/builders/src/messages/AttachmentBuilder.test.ts +79 -0
- package/core/packages/builders/src/messages/AttachmentBuilder.ts +69 -0
- package/core/packages/builders/src/messages/EmbedBuilder.test.ts +266 -0
- package/core/packages/builders/src/messages/EmbedBuilder.ts +239 -0
- package/core/packages/builders/src/messages/MessagePayload.test.ts +118 -0
- package/core/packages/builders/src/messages/MessagePayload.ts +122 -0
- package/core/packages/builders/tsconfig.json +9 -0
- package/core/packages/builders/tsup.config.ts +9 -0
- package/core/packages/builders/vitest.config.ts +9 -0
- package/core/packages/collection/package.json +47 -0
- package/core/packages/collection/src/Collection.test.ts +232 -0
- package/core/packages/collection/src/Collection.ts +196 -0
- package/core/packages/collection/src/index.ts +1 -0
- package/core/packages/collection/tsconfig.json +9 -0
- package/core/packages/collection/tsup.config.ts +9 -0
- package/core/packages/collection/vitest.config.ts +9 -0
- package/core/packages/docgen/package.json +26 -0
- package/core/packages/docgen/src/extract.ts +262 -0
- package/core/packages/docgen/src/formatType.ts +24 -0
- package/core/packages/docgen/src/index.ts +103 -0
- package/core/packages/docgen/src/schema.ts +100 -0
- package/core/packages/docgen/src/visitor.ts +147 -0
- package/core/packages/docgen/tsconfig.json +9 -0
- package/core/packages/docgen/tsup.config.ts +9 -0
- package/core/packages/fluxer-core/README.md +26 -0
- package/core/packages/fluxer-core/package.json +60 -0
- package/core/packages/fluxer-core/src/client/ChannelManager.ts +143 -0
- package/core/packages/fluxer-core/src/client/Client.gateway.test.ts +84 -0
- package/core/packages/fluxer-core/src/client/Client.resolveEmoji.test.ts +45 -0
- package/core/packages/fluxer-core/src/client/Client.ts +558 -0
- package/core/packages/fluxer-core/src/client/ClientUser.ts +40 -0
- package/core/packages/fluxer-core/src/client/EventHandlerRegistry.ts +469 -0
- package/core/packages/fluxer-core/src/client/GuildManager.ts +79 -0
- package/core/packages/fluxer-core/src/client/GuildMemberManager.ts +91 -0
- package/core/packages/fluxer-core/src/client/MessageManager.ts +58 -0
- package/core/packages/fluxer-core/src/client/UsersManager.ts +122 -0
- package/core/packages/fluxer-core/src/errors/ErrorCodes.test.ts +19 -0
- package/core/packages/fluxer-core/src/errors/ErrorCodes.ts +12 -0
- package/core/packages/fluxer-core/src/errors/FluxerError.test.ts +32 -0
- package/core/packages/fluxer-core/src/errors/FluxerError.ts +15 -0
- package/core/packages/fluxer-core/src/index.ts +85 -0
- package/core/packages/fluxer-core/src/structures/Base.ts +7 -0
- package/core/packages/fluxer-core/src/structures/Channel.ts +508 -0
- package/core/packages/fluxer-core/src/structures/Guild.test.ts +189 -0
- package/core/packages/fluxer-core/src/structures/Guild.ts +734 -0
- package/core/packages/fluxer-core/src/structures/GuildBan.ts +35 -0
- package/core/packages/fluxer-core/src/structures/GuildEmoji.ts +57 -0
- package/core/packages/fluxer-core/src/structures/GuildMember.test.ts +203 -0
- package/core/packages/fluxer-core/src/structures/GuildMember.ts +213 -0
- package/core/packages/fluxer-core/src/structures/GuildMemberRoleManager.ts +121 -0
- package/core/packages/fluxer-core/src/structures/GuildSticker.ts +56 -0
- package/core/packages/fluxer-core/src/structures/Invite.test.ts +103 -0
- package/core/packages/fluxer-core/src/structures/Invite.ts +121 -0
- package/core/packages/fluxer-core/src/structures/Message.test.ts +109 -0
- package/core/packages/fluxer-core/src/structures/Message.ts +397 -0
- package/core/packages/fluxer-core/src/structures/MessageReaction.ts +72 -0
- package/core/packages/fluxer-core/src/structures/PartialMessage.ts +12 -0
- package/core/packages/fluxer-core/src/structures/Role.test.ts +77 -0
- package/core/packages/fluxer-core/src/structures/Role.ts +112 -0
- package/core/packages/fluxer-core/src/structures/User.test.ts +110 -0
- package/core/packages/fluxer-core/src/structures/User.ts +109 -0
- package/core/packages/fluxer-core/src/structures/Webhook.test.ts +109 -0
- package/core/packages/fluxer-core/src/structures/Webhook.ts +258 -0
- package/core/packages/fluxer-core/src/util/Constants.test.ts +16 -0
- package/core/packages/fluxer-core/src/util/Constants.ts +7 -0
- package/core/packages/fluxer-core/src/util/Events.ts +46 -0
- package/core/packages/fluxer-core/src/util/MessageCollector.ts +87 -0
- package/core/packages/fluxer-core/src/util/Options.ts +33 -0
- package/core/packages/fluxer-core/src/util/ReactionCollector.ts +116 -0
- package/core/packages/fluxer-core/src/util/cdn.test.ts +108 -0
- package/core/packages/fluxer-core/src/util/cdn.ts +130 -0
- package/core/packages/fluxer-core/src/util/guildUtils.ts +33 -0
- package/core/packages/fluxer-core/src/util/messageUtils.test.ts +74 -0
- package/core/packages/fluxer-core/src/util/messageUtils.ts +119 -0
- package/core/packages/fluxer-core/src/util/permissions.test.ts +95 -0
- package/core/packages/fluxer-core/src/util/permissions.ts +43 -0
- package/core/packages/fluxer-core/tsconfig.json +9 -0
- package/core/packages/fluxer-core/tsup.config.ts +9 -0
- package/core/packages/fluxer-core/vitest.config.ts +9 -0
- package/core/packages/rest/package.json +52 -0
- package/core/packages/rest/src/REST.test.ts +64 -0
- package/core/packages/rest/src/REST.ts +90 -0
- package/core/packages/rest/src/RateLimitManager.test.ts +71 -0
- package/core/packages/rest/src/RateLimitManager.ts +60 -0
- package/core/packages/rest/src/RequestManager.test.ts +87 -0
- package/core/packages/rest/src/RequestManager.ts +172 -0
- package/core/packages/rest/src/errors/FluxerAPIError.test.ts +57 -0
- package/core/packages/rest/src/errors/FluxerAPIError.ts +21 -0
- package/core/packages/rest/src/errors/HTTPError.test.ts +55 -0
- package/core/packages/rest/src/errors/HTTPError.ts +25 -0
- package/core/packages/rest/src/errors/RateLimitError.test.ts +41 -0
- package/core/packages/rest/src/errors/RateLimitError.ts +15 -0
- package/core/packages/rest/src/errors/index.ts +3 -0
- package/core/packages/rest/src/index.ts +6 -0
- package/core/packages/rest/src/utils/constants.test.ts +31 -0
- package/core/packages/rest/src/utils/constants.ts +5 -0
- package/core/packages/rest/src/utils/files.test.ts +37 -0
- package/core/packages/rest/src/utils/files.ts +75 -0
- package/core/packages/rest/tsconfig.json +9 -0
- package/core/packages/rest/tsup.config.ts +9 -0
- package/core/packages/rest/vitest.config.ts +9 -0
- package/core/packages/types/package.json +46 -0
- package/core/packages/types/src/api/ban.ts +8 -0
- package/core/packages/types/src/api/channel.ts +65 -0
- package/core/packages/types/src/api/embed.ts +82 -0
- package/core/packages/types/src/api/emoji.ts +12 -0
- package/core/packages/types/src/api/errors.ts +68 -0
- package/core/packages/types/src/api/gateway.ts +14 -0
- package/core/packages/types/src/api/guild.ts +123 -0
- package/core/packages/types/src/api/index.ts +15 -0
- package/core/packages/types/src/api/instance.ts +32 -0
- package/core/packages/types/src/api/interaction.ts +26 -0
- package/core/packages/types/src/api/invite.ts +28 -0
- package/core/packages/types/src/api/message.ts +140 -0
- package/core/packages/types/src/api/role.ts +41 -0
- package/core/packages/types/src/api/sticker.ts +14 -0
- package/core/packages/types/src/api/user.ts +79 -0
- package/core/packages/types/src/api/webhook.ts +41 -0
- package/core/packages/types/src/common/index.ts +1 -0
- package/core/packages/types/src/common/snowflake.test.ts +9 -0
- package/core/packages/types/src/common/snowflake.ts +8 -0
- package/core/packages/types/src/gateway/events.ts +189 -0
- package/core/packages/types/src/gateway/index.ts +3 -0
- package/core/packages/types/src/gateway/opcodes.ts +17 -0
- package/core/packages/types/src/gateway/payloads.ts +481 -0
- package/core/packages/types/src/index.ts +4 -0
- package/core/packages/types/src/rest/index.ts +1 -0
- package/core/packages/types/src/rest/routes.test.ts +169 -0
- package/core/packages/types/src/rest/routes.ts +109 -0
- package/core/packages/types/tsconfig.json +9 -0
- package/core/packages/types/tsup.config.ts +9 -0
- package/core/packages/types/vitest.config.ts +9 -0
- package/core/packages/util/package.json +51 -0
- package/core/packages/util/src/BitField.test.ts +96 -0
- package/core/packages/util/src/BitField.ts +105 -0
- package/core/packages/util/src/MessageFlagsBitField.test.ts +42 -0
- package/core/packages/util/src/MessageFlagsBitField.ts +20 -0
- package/core/packages/util/src/PermissionsBitField.test.ts +79 -0
- package/core/packages/util/src/PermissionsBitField.ts +97 -0
- package/core/packages/util/src/SnowflakeUtil.test.ts +69 -0
- package/core/packages/util/src/SnowflakeUtil.ts +65 -0
- package/core/packages/util/src/UserFlagsBitField.test.ts +39 -0
- package/core/packages/util/src/UserFlagsBitField.ts +48 -0
- package/core/packages/util/src/deprecation.test.ts +44 -0
- package/core/packages/util/src/deprecation.ts +28 -0
- package/core/packages/util/src/emojiShortcodes.generated.ts +5 -0
- package/core/packages/util/src/emojiShortcodes.test.ts +41 -0
- package/core/packages/util/src/emojiShortcodes.ts +22 -0
- package/core/packages/util/src/formatters.test.ts +65 -0
- package/core/packages/util/src/formatters.ts +35 -0
- package/core/packages/util/src/index.ts +34 -0
- package/core/packages/util/src/resolvers.test.ts +198 -0
- package/core/packages/util/src/resolvers.ts +127 -0
- package/core/packages/util/src/tenorUtils.test.ts +75 -0
- package/core/packages/util/src/tenorUtils.ts +86 -0
- package/core/packages/util/tsconfig.json +9 -0
- package/core/packages/util/tsup.config.ts +9 -0
- package/core/packages/util/vitest.config.ts +9 -0
- package/core/packages/voice/README.md +42 -0
- package/core/packages/voice/package.json +67 -0
- package/core/packages/voice/src/LiveKitRtcConnection.receive.test.ts +24 -0
- package/core/packages/voice/src/LiveKitRtcConnection.ts +1767 -0
- package/core/packages/voice/src/VoiceConnection.ts +413 -0
- package/core/packages/voice/src/VoiceManager.receive.test.ts +61 -0
- package/core/packages/voice/src/VoiceManager.test.ts +44 -0
- package/core/packages/voice/src/VoiceManager.ts +503 -0
- package/core/packages/voice/src/exports.test.ts +38 -0
- package/core/packages/voice/src/index.ts +51 -0
- package/core/packages/voice/src/livekit.test.ts +48 -0
- package/core/packages/voice/src/livekit.ts +33 -0
- package/core/packages/voice/src/mp4box.d.ts +32 -0
- package/core/packages/voice/src/opusUtils.test.ts +29 -0
- package/core/packages/voice/src/opusUtils.ts +86 -0
- package/core/packages/voice/src/streamPreviewPlaceholder.test.ts +16 -0
- package/core/packages/voice/src/streamPreviewPlaceholder.ts +8 -0
- package/core/packages/voice/src/ws.d.ts +1 -0
- package/core/packages/voice/tsconfig.json +5 -0
- package/core/packages/voice/tsup.config.ts +10 -0
- package/core/packages/voice/vitest.config.ts +9 -0
- package/core/packages/ws/package.json +52 -0
- package/core/packages/ws/src/WebSocketManager.ts +130 -0
- package/core/packages/ws/src/WebSocketShard.ts +296 -0
- package/core/packages/ws/src/index.ts +12 -0
- package/core/packages/ws/src/utils/constants.test.ts +46 -0
- package/core/packages/ws/src/utils/constants.ts +22 -0
- package/core/packages/ws/src/utils/getWebSocket.ts +55 -0
- package/core/packages/ws/src/ws.d.ts +10 -0
- package/core/packages/ws/tsconfig.json +9 -0
- package/core/packages/ws/tsup.config.ts +9 -0
- package/core/pnpm-lock.yaml +7033 -0
- package/core/pnpm-workspace.yaml +4 -0
- package/core/scripts/generate-ai-rag.ts +240 -0
- package/core/scripts/generate-docs.ts +143 -0
- package/core/scripts/generate-emoji-shortcodes.ts +58 -0
- package/core/scripts/generate-types.ts +6 -0
- package/core/scripts/publish-ordered.js +63 -0
- package/core/scripts/test-cjs-require.mjs +43 -0
- package/core/scripts/test-esm-imports.mjs +42 -0
- package/core/scripts/test-package-exports.mjs +98 -0
- package/core/scripts/test-smoke.mjs +103 -0
- package/core/tsconfig.json +18 -0
- package/core/turbo.json +30 -0
- package/core/vitest.config.ts +17 -0
- package/core/wrangler.jsonc +9 -0
- package/package.json +26 -0
|
@@ -0,0 +1,1293 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "installation",
|
|
4
|
+
"slug": "installation",
|
|
5
|
+
"title": "Installation",
|
|
6
|
+
"description": "Install the package and configure your bot token.",
|
|
7
|
+
"category": "getting-started",
|
|
8
|
+
"sections": [
|
|
9
|
+
{
|
|
10
|
+
"code": "npm install @fluxerjs/core\n\n# Run your bot (Node 18+)\nFLUXER_BOT_TOKEN=your_token node your-bot.js",
|
|
11
|
+
"language": "bash"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "basic-bot",
|
|
17
|
+
"slug": "basic-bot",
|
|
18
|
+
"title": "Basic Bot",
|
|
19
|
+
"description": "A minimal bot that responds to !ping with Pong. See examples/first-steps-bot.js for !hello, !avatar, !embed, !perms.",
|
|
20
|
+
"category": "getting-started",
|
|
21
|
+
"sections": [
|
|
22
|
+
{
|
|
23
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.Ready, () => console.log('Ready!'));\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!ping') {\n await message.reply('Pong!');\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
24
|
+
"language": "javascript",
|
|
25
|
+
"tip": "You can also use client.events for chainable, typed handlers with better autocomplete.",
|
|
26
|
+
"alternateCode": {
|
|
27
|
+
"label": "client.events",
|
|
28
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient\n .events.Ready(() => console.log('Ready!'))\n .events.MessageCreate(async (message) => {\n if (message.content === '!ping') await message.reply('Pong!');\n });\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"title": "Common mistakes",
|
|
33
|
+
"description": "Always await message.reply() to avoid unhandled promise rejections. Use intents: 0 (Fluxer does not support intents yet). Set FLUXER_SUPPRESS_DEPRECATION=1 to silence deprecation warnings.",
|
|
34
|
+
"code": "// ❌ BAD — unhandled rejection if reply fails\nmessage.reply('Pong!');\n\n// ✅ GOOD\nawait message.reply('Pong!');",
|
|
35
|
+
"language": "javascript"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "discord-js-compatibility",
|
|
41
|
+
"slug": "discord-js-compatibility",
|
|
42
|
+
"title": "Discord.js Compatibility",
|
|
43
|
+
"description": "APIs designed to ease migration from Discord.js. Look for the green \"Discord.js compatible\" badge in guides.",
|
|
44
|
+
"category": "getting-started",
|
|
45
|
+
"sections": [
|
|
46
|
+
{
|
|
47
|
+
"title": "Overview",
|
|
48
|
+
"description": "Fluxer SDK provides Discord.js-style APIs where it makes sense. Sections marked with the green \"Discord.js compatible\" badge offer familiar patterns — click the badge to see the full API reference."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"title": "member.roles (GuildMemberRoleManager)",
|
|
52
|
+
"discordJsCompat": "/docs/classes/GuildMemberRoleManager",
|
|
53
|
+
"description": "member.roles is a manager with add(), remove(), set(), and cache. Use member.roles.add(roleId), member.roles.remove(roleId), member.roles.set(roleIds), and member.roles.cache.has(roleId) instead of the old member.addRole() / member.roles.includes() pattern.",
|
|
54
|
+
"code": "// Discord.js style\nawait member.roles.add(roleId);\nawait member.roles.remove(roleId);\nawait member.roles.set(['id1', 'id2']);\nif (member.roles.cache.has(roleId)) { ... }",
|
|
55
|
+
"language": "javascript"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"title": "guild.members.me",
|
|
59
|
+
"discordJsCompat": "/docs/classes/GuildMemberManager",
|
|
60
|
+
"description": "guild.members.me returns the bot's GuildMember in that guild. Use guild.members.fetchMe() to load it when not cached. Same as Discord.js.",
|
|
61
|
+
"code": "const me = guild.members.me ?? await guild.members.fetchMe();\nif (me?.permissions.has(PermissionFlags.BanMembers)) {\n await message.reply('I can ban members here.');\n}",
|
|
62
|
+
"language": "javascript"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"title": "Other parity",
|
|
66
|
+
"description": "client.channels.cache and client.guilds.cache are compatibility aliases. Collection extends Map with find(), filter(), etc. See the API reference for full details."
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "sending-without-reply",
|
|
72
|
+
"slug": "sending-without-reply",
|
|
73
|
+
"title": "Sending Without Reply",
|
|
74
|
+
"description": "Send messages to the same channel or to specific channels. Covers message.send(), message.sendTo(), client.channels.send(), and client.channels.resolve().",
|
|
75
|
+
"category": "sending-messages",
|
|
76
|
+
"sections": [
|
|
77
|
+
{
|
|
78
|
+
"title": "message.send() vs message.reply()",
|
|
79
|
+
"description": "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."
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"title": "Sending to the same channel",
|
|
83
|
+
"description": "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.",
|
|
84
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!hello') {\n await message.send('Hello! This is a regular message, not a reply.');\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
85
|
+
"language": "javascript"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"title": "Sending to a specific channel (e.g. logging)",
|
|
89
|
+
"description": "Use message.sendTo(channelId, payload) to send to another channel—handy for logging, announcements, or forwarding. You only need the target channel ID.",
|
|
90
|
+
"code": "import { Client, Events, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nconst LOG_CHANNEL_ID = process.env.LOG_CHANNEL_ID; // Your log channel's snowflake\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!report' && message.guildId && LOG_CHANNEL_ID) {\n const embed = new EmbedBuilder()\n .setTitle('User report')\n .setDescription(message.content)\n .addFields(\n { name: 'Author', value: message.author.username, inline: true },\n { name: 'Channel', value: `<#${message.channelId}>`, inline: true }\n )\n .setTimestamp();\n\n await message.sendTo(LOG_CHANNEL_ID, { embeds: [embed] });\n await message.send('Report logged.');\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
91
|
+
"language": "javascript"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"title": "client.channels.send() — send by channel ID",
|
|
95
|
+
"description": "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.",
|
|
96
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nconst ANNOUNCE_CHANNEL_ID = process.env.ANNOUNCE_CHANNEL_ID;\n\nclient.on(Events.Ready, async () => {\n if (ANNOUNCE_CHANNEL_ID) {\n await client.channels.send(ANNOUNCE_CHANNEL_ID, 'Bot is online!');\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
97
|
+
"language": "javascript"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"title": "client.channels.resolve() — get channel by ID",
|
|
101
|
+
"description": "Resolve a channel by ID from cache or API. Use channel.isSendable() before sending. For sending when you only have an ID, prefer client.channels.send() which skips the fetch.",
|
|
102
|
+
"code": "import { Client } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nawait client.login(process.env.FLUXER_BOT_TOKEN);\n\n// Fetch channel (from API if not cached)\nconst channel = await client.channels.resolve(channelId);\nif (channel?.isSendable()) {\n await channel.send('Hello!');\n}\n// Or for webhooks: if (channel?.createWebhook) { ... }",
|
|
103
|
+
"language": "javascript"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"title": "fetch message by id",
|
|
107
|
+
"description": "Use channel.messages.fetch(messageId) when you have the channel. For IDs-only, fetch the channel first.",
|
|
108
|
+
"code": "// When you have the channel\nconst message = await channel.messages.fetch(messageId);\nif (message) {\n await message.edit({ content: 'Updated!' });\n await message.react('👍');\n}\n\n// When you only have IDs (e.g. from sqlite)\nconst ch = await client.channels.resolve(channelId);\nconst msg = await ch?.messages?.fetch(messageId);\nif (msg) await msg.delete();\n\n// When channel is cached\nconst m = client.channels.get(channelId);\nif (m?.isSendable()) {\n const mes = await m.messages.fetch(messageId);\n if (mes) await mes.edit({ content: 'Edited!' });\n}\n\n// Refresh a stale message instance\nconst updated = await message.fetch();\nif (updated) console.log(updated.content);",
|
|
109
|
+
"language": "javascript"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"title": "message.channel and message.guild",
|
|
113
|
+
"description": "Access the channel or guild from a message. Resolved from cache; null if not cached (e.g. DM channel).",
|
|
114
|
+
"code": "client.on(Events.MessageCreate, async (message) => {\n const channel = message.channel; // TextChannel or DMChannel | null\n const guild = message.guild; // Guild | null (null for DMs)\n if (message.channel?.isSendable()) {\n await message.channel.send('Same channel, different API');\n }\n});",
|
|
115
|
+
"language": "javascript"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"title": "Typing indicator",
|
|
119
|
+
"description": "Use channel.sendTyping() before a slow operation so users see \"Bot is typing...\". Lasts ~10 seconds.",
|
|
120
|
+
"code": "const channel = message.channel ?? (await message.resolveChannel());\nif (channel?.isSendable?.()) {\n await channel.sendTyping();\n await slowOperation(); // e.g. fetch external API\n await message.reply('Done!');\n}",
|
|
121
|
+
"language": "javascript"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"title": "Quick reference",
|
|
125
|
+
"code": "// Same channel, no reply\nawait message.send('Pong!');\n\n// Reply to the message\nawait message.reply('Pong!');\n\n// Send to a specific channel\nawait message.sendTo(logChannelId, 'User joined!');\nawait client.channels.send(channelId, 'New update available!');",
|
|
126
|
+
"language": "javascript"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "embeds",
|
|
132
|
+
"slug": "embeds",
|
|
133
|
+
"title": "Embeds",
|
|
134
|
+
"description": "Complete reference for EmbedBuilder: title, description, author, footer, fields, color, media, and more.",
|
|
135
|
+
"category": "sending-messages",
|
|
136
|
+
"sections": [
|
|
137
|
+
{
|
|
138
|
+
"title": "Overview",
|
|
139
|
+
"description": "Use EmbedBuilder to create rich embeds. EmbedBuilder instances are auto-converted—no need to call .toJSON() when passing to reply(), send(), or edit(). An embed must have at least one of: title, description, fields, or image/thumbnail. A description-only embed (no title) is valid."
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"title": "Basic embed",
|
|
143
|
+
"description": "Minimal embed with title, description, color, fields, footer, and timestamp.",
|
|
144
|
+
"code": "import { Client, Events, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!embed') {\n const embed = new EmbedBuilder()\n .setTitle('Hello!')\n .setDescription('This is a Fluxer embed.')\n .setColor(0x5865f2)\n .addFields(\n { name: 'Field 1', value: 'Value 1', inline: true },\n { name: 'Field 2', value: 'Value 2', inline: true }\n )\n .setFooter({ text: 'Powered by Fluxer.js' })\n .setTimestamp();\n\n await message.reply({ embeds: [embed] });\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
145
|
+
"language": "javascript"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"title": "Title, Description, and URL",
|
|
149
|
+
"description": "setTitle() and setDescription() accept strings (max 256 and 4096 chars). setURL() makes the title a clickable link.",
|
|
150
|
+
"code": "const embed = new EmbedBuilder()\n .setTitle('Clickable Title')\n .setDescription('Main body text here.')\n .setURL('https://example.com');",
|
|
151
|
+
"language": "javascript"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"title": "Color",
|
|
155
|
+
"description": "setColor() accepts: number (0x5865f2), hex string (\"#5865f2\"), or [r, g, b] array.",
|
|
156
|
+
"code": "embed.setColor(0x5865f2);\nembed.setColor('#57f287');\nembed.setColor([88, 101, 242]);",
|
|
157
|
+
"language": "javascript"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"title": "Author",
|
|
161
|
+
"description": "setAuthor() adds a header line with name. Optional: iconURL, url.",
|
|
162
|
+
"code": "embed.setAuthor({\n name: 'Fluxer.js',\n iconURL: 'https://example.com/icon.png',\n url: 'https://fluxerjs.dev',\n});",
|
|
163
|
+
"language": "javascript"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"title": "Footer",
|
|
167
|
+
"description": "setFooter() adds text at the bottom. Optional: iconURL.",
|
|
168
|
+
"code": "embed.setFooter({\n text: 'Powered by Fluxer.js',\n iconURL: 'https://example.com/footer-icon.png',\n});",
|
|
169
|
+
"language": "javascript"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"title": "Timestamp",
|
|
173
|
+
"description": "setTimestamp() shows a date. Omit or pass null for current time. Pass Date or number (ms) for a specific time.",
|
|
174
|
+
"code": "embed.setTimestamp(); // current time\nembed.setTimestamp(new Date('2026-01-01'));\nembed.setTimestamp(Date.now() - 3600000); // 1 hour ago",
|
|
175
|
+
"language": "javascript"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"title": "Fields",
|
|
179
|
+
"description": "addFields() adds name/value pairs. Max 25 fields. Use inline: true for side-by-side layout. spliceFields() to insert/remove.",
|
|
180
|
+
"code": "embed.addFields(\n { name: 'Field 1', value: 'Value 1', inline: true },\n { name: 'Field 2', value: 'Value 2', inline: true },\n { name: 'Long field', value: 'Not inline, full width' }\n);\n\n// Insert/replace fields\nembed.spliceFields(1, 1, { name: 'Replaced', value: 'New value' });",
|
|
181
|
+
"language": "javascript"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"title": "Image and Thumbnail",
|
|
185
|
+
"description": "setImage() adds a large image. setThumbnail() adds a small image (e.g. top-right). Pass a URL string or EmbedMediaOptions (url, width, height, content_type, etc).",
|
|
186
|
+
"code": "embed.setImage('https://example.com/image.png');\nembed.setThumbnail('https://example.com/thumb.png');\n\n// With metadata\nembed.setImage({\n url: 'https://example.com/image.png',\n width: 400,\n height: 200,\n content_type: 'image/png',\n});",
|
|
187
|
+
"language": "javascript"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"title": "Video and Audio",
|
|
191
|
+
"description": "setVideo() and setAudio() add video/audio to embeds (Fluxer supports these). Pass URL or EmbedMediaOptions. Include a title when using video. See Embed Media guide for full examples.",
|
|
192
|
+
"code": "embed.setVideo('https://example.com/video.mp4');\nembed.setAudio({\n url: 'https://example.com/audio.mp3',\n duration: 120,\n content_type: 'audio/mpeg',\n});",
|
|
193
|
+
"language": "javascript"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"title": "Multiple embeds",
|
|
197
|
+
"description": "Messages can include up to 10 embeds. Pass an array to embeds.",
|
|
198
|
+
"code": "await message.reply({\n embeds: [\n new EmbedBuilder().setTitle('First').setColor(0x5865f2),\n new EmbedBuilder().setTitle('Second').setColor(0x57f287),\n ],\n});",
|
|
199
|
+
"language": "javascript"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"title": "Load from existing embed",
|
|
203
|
+
"description": "EmbedBuilder.from() creates a builder from an API embed (e.g. from a received message). Edit and toJSON() to send.",
|
|
204
|
+
"code": "const existing = message.embeds[0];\nif (existing) {\n const edited = EmbedBuilder.from(existing)\n .setTitle('Updated title')\n .setColor(0x57f287);\n await message.edit({ embeds: [edited] });\n}",
|
|
205
|
+
"language": "javascript"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"title": "Limits",
|
|
209
|
+
"description": "Title ≤256, description ≤4096, field name ≤256, field value ≤1024, footer ≤2048, author name ≤256. Max 25 fields. Combined title+description+fields+footer ≤6000 chars."
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "editing-embeds",
|
|
215
|
+
"slug": "editing-embeds",
|
|
216
|
+
"title": "Editing Embeds",
|
|
217
|
+
"description": "Edit existing message embeds with message.edit().",
|
|
218
|
+
"category": "sending-messages",
|
|
219
|
+
"sections": [
|
|
220
|
+
{
|
|
221
|
+
"title": "Overview",
|
|
222
|
+
"description": "The Fluxer API supports editing existing messages via PATCH. You can update the message content, embeds, or both. Only the message author (or admins with proper permissions) can edit messages."
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"title": "Edit Content",
|
|
226
|
+
"description": "Update the text content of a message you sent.",
|
|
227
|
+
"code": "const reply = await message.reply('Initial message');\nawait reply.edit({ content: 'Updated message!' });",
|
|
228
|
+
"language": "javascript"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"title": "Edit Embeds",
|
|
232
|
+
"description": "Replace or update embeds on an existing message. Pass an array of EmbedBuilder instances or APIEmbed objects.",
|
|
233
|
+
"code": "import { Client, Events, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!editembed') {\n const embed = new EmbedBuilder()\n .setTitle('Loading...')\n .setColor(0x5865f2)\n .setTimestamp();\n\n const reply = await message.reply({ embeds: [embed] });\n\n // Simulate loading, then update the embed\n await new Promise((r) => setTimeout(r, 2000));\n\n const updatedEmbed = new EmbedBuilder()\n .setTitle('Done!')\n .setDescription('This embed was edited after 2 seconds.')\n .setColor(0x57f287)\n .setTimestamp();\n\n await reply.edit({ embeds: [updatedEmbed] });\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
234
|
+
"language": "javascript"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"title": "Edit Content and Embeds Together",
|
|
238
|
+
"description": "You can update both content and embeds in a single edit call.",
|
|
239
|
+
"code": "await message.edit({\n content: 'Updated text',\n embeds: [new EmbedBuilder().setTitle('Updated embed').setColor(0x5865f2)],\n});",
|
|
240
|
+
"language": "javascript"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"title": "API Reference",
|
|
244
|
+
"description": "The edit endpoint is PATCH /channels/{channel_id}/messages/{message_id}. See openapi.json for the full request body schema. The SDK Message.edit() accepts { content?: string; embeds?: (APIEmbed | EmbedBuilder)[] }."
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"id": "embed-media",
|
|
250
|
+
"slug": "embed-media",
|
|
251
|
+
"title": "Embed Media",
|
|
252
|
+
"description": "Add images, thumbnails, video, and audio to embeds with EmbedBuilder and EmbedMediaOptions.",
|
|
253
|
+
"category": "media",
|
|
254
|
+
"sections": [
|
|
255
|
+
{
|
|
256
|
+
"title": "Images and Thumbnails",
|
|
257
|
+
"description": "Use setImage() and setThumbnail() with a URL string, or pass full EmbedMediaOptions for width, height, content_type, and other metadata.",
|
|
258
|
+
"code": "import { Client, Events, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!embedimg') {\n const embed = new EmbedBuilder()\n .setTitle('Image Embed')\n .setDescription('Simple image from URL.')\n .setImage('https://placehold.co/400x200/5865f2/white?text=Image')\n .setThumbnail('https://placehold.co/100x100/57f287/white?text=Thumb')\n .setColor(0x5865f2);\n\n await message.reply({ embeds: [embed] });\n }\n});",
|
|
259
|
+
"language": "javascript"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"title": "Image with Full Media Options",
|
|
263
|
+
"description": "Pass an object to setImage or setThumbnail with url, width, height, content_type, description, placeholder, duration, and flags. Use EmbedMediaFlags.IS_ANIMATED for animated GIFs.",
|
|
264
|
+
"code": "const embed = new EmbedBuilder()\n .setTitle('Image with metadata')\n .setDescription('EmbedMediaOptions: width, height')\n .setImage({\n url: 'https://placehold.co/400x200/5865f2/white?text=Image',\n width: 400,\n height: 200,\n content_type: 'image/png',\n })\n .setColor(0x5865f2);",
|
|
265
|
+
"language": "javascript"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"title": "GIFs in embeds",
|
|
269
|
+
"description": "Embeds require GIF format for animated images (not MP4). Add EmbedMediaFlags.IS_ANIMATED to the flags field. For Tenor URLs, use resolveTenorToImageUrl() to get the GIF URL and flag — see the GIFs (Tenor) guide."
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"title": "Video in Embeds",
|
|
273
|
+
"description": "Use setVideo() to add video to a rich embed. Fluxer supports the .video field. Include a title when using video. Pass a URL or EmbedMediaOptions (e.g. duration for progress bars).",
|
|
274
|
+
"code": "const embed = new EmbedBuilder()\n .setTitle('Video embed')\n .setDescription('Rich embed with video field.')\n .setVideo('https://example.com/sample.mp4')\n .setURL('https://example.com/sample.mp4')\n .setColor(0x5865f2);\n\n// With full options (duration, dimensions for progress bar):\nconst embedWithDuration = new EmbedBuilder()\n .setTitle('Video with metadata')\n .setVideo({\n url: 'https://example.com/video.mp4',\n duration: 120,\n width: 1280,\n height: 720,\n })\n .setColor(0x5865f2);",
|
|
275
|
+
"language": "javascript"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"title": "Audio in Embeds",
|
|
279
|
+
"description": "Use setAudio() to add audio to an embed. Pass a URL or EmbedMediaOptions (e.g. duration, content_type).",
|
|
280
|
+
"code": "const embed = new EmbedBuilder()\n .setTitle('Audio embed')\n .setDescription('Rich embed with audio field.')\n .setAudio({\n url: 'https://example.com/sample.mp3',\n duration: 180,\n content_type: 'audio/mpeg',\n })\n .setColor(0x5865f2);",
|
|
281
|
+
"language": "javascript"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"id": "gifs",
|
|
287
|
+
"slug": "gifs",
|
|
288
|
+
"title": "GIFs (Tenor)",
|
|
289
|
+
"description": "Send Tenor GIFs as content (gifv) or in embeds using resolveTenorToImageUrl() for GIF URLs.",
|
|
290
|
+
"category": "media",
|
|
291
|
+
"sections": [
|
|
292
|
+
{
|
|
293
|
+
"title": "How Tenor GIFs Work",
|
|
294
|
+
"description": "Tenor embeds are created by the Fluxer unfurler when you send a Tenor URL as message content. Do not use custom embeds for Tenor GIFs—the API turns the URL into a type: \"gifv\" embed."
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"title": "Send a Tenor GIF",
|
|
298
|
+
"description": "Send the Tenor URL as content. No embeds needed. The unfurler detects the URL and creates the gifv embed.",
|
|
299
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!gif') {\n const tenorUrl = 'https://tenor.com/view/stressed-gif-7048057395502071840';\n await message.reply({ content: tenorUrl });\n }\n});",
|
|
300
|
+
"language": "javascript"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"title": "Tenor URL in an embed",
|
|
304
|
+
"description": "Tenor page URLs do not work as setImage() URLs. Use resolveTenorToImageUrl() to fetch the Tenor page or oEmbed, derive the GIF URL (embeds require GIF, not MP4), and return { url, flags: IS_ANIMATED }. For full gifv embeds, send the Tenor URL as content.",
|
|
305
|
+
"code": "import { EmbedBuilder, resolveTenorToImageUrl } from '@fluxerjs/core';\n\nconst tenorUrl = 'https://tenor.com/view/stressed-gif-7048057395502071840';\nconst media = await resolveTenorToImageUrl(tenorUrl);\nif (media) {\n const embed = new EmbedBuilder()\n .setTitle('Tenor in embed')\n .setDescription('GIF URL + IS_ANIMATED flag')\n .setImage(media)\n .setColor(0x5865f2);\n await message.reply({ embeds: [embed] });\n}",
|
|
306
|
+
"language": "javascript"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"title": "Important",
|
|
310
|
+
"description": "Custom embeds cannot create gifv embeds. For full animated gifv, send the Tenor URL as content. resolveTenorToImageUrl() returns GIF URL + IS_ANIMATED (derived from media.tenor.com path)."
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"id": "attachments",
|
|
316
|
+
"slug": "attachments",
|
|
317
|
+
"title": "File Attachments",
|
|
318
|
+
"description": "Upload files with messages and set attachment metadata (title, description, flags for spoiler, animated, explicit).",
|
|
319
|
+
"category": "media",
|
|
320
|
+
"sections": [
|
|
321
|
+
{
|
|
322
|
+
"title": "Basic File Upload",
|
|
323
|
+
"description": "Pass files in your send options. Each file needs a name and data (Buffer, Blob, Uint8Array). Use with message.reply(), message.send(), or channel.send().",
|
|
324
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\nimport { readFileSync } from 'fs';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!file') {\n const data = Buffer.from('Hello from Fluxer!', 'utf-8');\n await message.reply({\n content: 'Here is a file:',\n files: [{ name: 'hello.txt', data }],\n });\n }\n});",
|
|
325
|
+
"language": "javascript"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"title": "Attachment Metadata",
|
|
329
|
+
"description": "When using files, you can pass attachments to set metadata per file: filename, title, description, and flags. The id in each attachment matches the file index (0, 1, 2...).",
|
|
330
|
+
"code": "import { MessageAttachmentFlags } from '@fluxerjs/core';\n\nawait message.reply({\n content: 'Spoiler image:',\n files: [{ name: 'secret.png', data: imageBuffer }],\n attachments: [\n {\n id: 0,\n filename: 'secret.png',\n title: 'Hidden image',\n flags: MessageAttachmentFlags.IS_SPOILER,\n },\n ],\n});",
|
|
331
|
+
"language": "javascript"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"title": "Attachment Flags",
|
|
335
|
+
"description": "MessageAttachmentFlags: IS_SPOILER (8) blurs until clicked, CONTAINS_EXPLICIT_MEDIA (16) for explicit content, IS_ANIMATED (32) for GIFs and animated WebP. Combine with bitwise OR.",
|
|
336
|
+
"code": "import { MessageAttachmentFlags } from '@fluxerjs/core';\n\n// Spoiler (blurred until clicked)\nflags: MessageAttachmentFlags.IS_SPOILER\n\n// Animated image (GIF, animated WebP)\nflags: MessageAttachmentFlags.IS_ANIMATED\n\n// Combine flags\nflags: MessageAttachmentFlags.IS_SPOILER | MessageAttachmentFlags.IS_ANIMATED",
|
|
337
|
+
"language": "javascript"
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"id": "attachments-by-url",
|
|
343
|
+
"slug": "attachments-by-url",
|
|
344
|
+
"title": "File Attachments by URL",
|
|
345
|
+
"description": "Attach files by passing a URL instead of buffer data. The SDK fetches the URL and uploads it as a normal attachment.",
|
|
346
|
+
"category": "media",
|
|
347
|
+
"sections": [
|
|
348
|
+
{
|
|
349
|
+
"title": "Using a URL",
|
|
350
|
+
"description": "Pass { name, url } in the files array. The SDK fetches the URL (30s timeout), validates it with URL.canParse(), and uploads the result. Works with channel.send(), message.reply(), message.send(), webhook.send(), and client.channels.send().",
|
|
351
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!attachurl') {\n await message.reply({\n content: 'Image from URL:',\n files: [\n {\n name: 'image.png',\n url: 'https://example.com/image.png',\n },\n ],\n });\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
352
|
+
"language": "javascript"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"title": "Mixing buffers and URLs",
|
|
356
|
+
"description": "You can combine file data and URLs in the same message. Order is preserved; attachments metadata id matches the file index.",
|
|
357
|
+
"code": "await message.reply({\n content: 'Two files:',\n files: [\n { name: 'local.txt', data: Buffer.from('Hello') },\n { name: 'remote.png', url: 'https://example.com/logo.png' },\n ],\n});",
|
|
358
|
+
"language": "javascript"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"title": "Optional filename override",
|
|
362
|
+
"description": "Use filename to control the displayed attachment name independently from the local name used during upload.",
|
|
363
|
+
"code": "files: [\n {\n name: 'fetched-image.png',\n url: 'https://example.com/image.jpg',\n filename: 'custom-display.png',\n },\n]",
|
|
364
|
+
"language": "javascript"
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"id": "profile-urls",
|
|
370
|
+
"slug": "profile-urls",
|
|
371
|
+
"title": "Profile URLs",
|
|
372
|
+
"description": "Get avatar, banner, and other CDN URLs easily with User/Webhook/GuildMember methods or standalone CDN helpers for raw API data.",
|
|
373
|
+
"category": "media",
|
|
374
|
+
"sections": [
|
|
375
|
+
{
|
|
376
|
+
"title": "User avatar and banner",
|
|
377
|
+
"description": "When you have a User object (e.g. message.author), use avatarURL(), displayAvatarURL(), and bannerURL(). These handle animated avatars (a_ prefix) and default fallbacks.",
|
|
378
|
+
"code": "import { Client, Events, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!avatar') {\n const user = message.author;\n // avatarURL() returns null if no custom avatar; displayAvatarURL() uses default\n const avatarUrl = user.displayAvatarURL({ size: 256 });\n const bannerUrl = user.bannerURL({ size: 512 });\n\n const embed = new EmbedBuilder()\n .setTitle(`${user.username}'s profile`)\n .setThumbnail(avatarUrl)\n .setColor(user.avatarColor ?? 0x5865f2);\n if (bannerUrl) embed.setImage(bannerUrl);\n await message.reply({ embeds: [embed] });\n }\n});",
|
|
379
|
+
"language": "javascript"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"title": "Raw API data: CDN helpers",
|
|
383
|
+
"description": "When you have raw API data (e.g. from client.rest.get(Routes.user(id))), use the standalone CDN helpers. They work with id + hash and support size and extension options.",
|
|
384
|
+
"code": "import { cdnAvatarURL, cdnBannerURL } from '@fluxerjs/core';\n\n// From REST response\nconst userData = await client.rest.get(Routes.user(userId));\nconst avatarUrl = cdnAvatarURL(userData.id, userData.avatar, { size: 256 });\nconst bannerUrl = cdnBannerURL(userData.id, profile?.banner ?? null, { size: 512 });\n\n// Or use User: client.getOrCreateUser(userData) then user.displayAvatarURL()\nconst user = client.getOrCreateUser(userData);\nconst avatarUrl2 = user.displayAvatarURL({ size: 256 });",
|
|
385
|
+
"language": "javascript"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"title": "Guild member and webhook avatars",
|
|
389
|
+
"description": "GuildMember has displayAvatarURL() (guild avatar or fallback to user) and bannerURL(). Webhook has avatarURL().",
|
|
390
|
+
"code": "// Member avatar (guild-specific or user fallback)\nconst memberAvatar = member.displayAvatarURL({ size: 128 });\n\n// Webhook avatar\nconst webhookAvatar = webhook.avatarURL({ size: 64 });",
|
|
391
|
+
"language": "javascript"
|
|
392
|
+
}
|
|
393
|
+
]
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"id": "reactions",
|
|
397
|
+
"slug": "reactions",
|
|
398
|
+
"title": "Reactions",
|
|
399
|
+
"description": "Add, remove, and listen for message reactions with Message.react(), removeReaction(), and reaction events.",
|
|
400
|
+
"category": "sending-messages",
|
|
401
|
+
"sections": [
|
|
402
|
+
{
|
|
403
|
+
"title": "Add a Reaction",
|
|
404
|
+
"description": "Use message.react() to add an emoji reaction as the bot. Pass a unicode emoji string or custom emoji { name, id }.",
|
|
405
|
+
"code": "const reply = await message.reply('React to this!');\nawait reply.react('👍');\nawait reply.react({ name: 'customemoji', id: '123456789012345678' });",
|
|
406
|
+
"language": "javascript"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"title": "Remove Reactions",
|
|
410
|
+
"description": "Remove the bot's reaction with removeReaction(emoji). Remove a specific user's reaction with removeReaction(emoji, userId). Clear all reactions with removeAllReactions() or removeReactionEmoji(emoji).",
|
|
411
|
+
"code": "// Remove the bot's reaction\nawait message.removeReaction('👍');\n\n// Remove a specific user's reaction (requires moderator permissions)\nawait message.removeReaction('👍', userId);\n\n// Remove all reactions of one emoji from the message\nawait message.removeReactionEmoji('👍');\n\n// Remove all reactions from the message\nawait message.removeAllReactions();",
|
|
412
|
+
"language": "javascript"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"title": "Listen for Reactions",
|
|
416
|
+
"description": "MessageReactionAdd and MessageReactionRemove emit (reaction, user, messageId, channelId, emoji, userId). Use client.on(Events.X, handler) or client.events.MessageReactionAdd(handler).",
|
|
417
|
+
"code": "client.on(Events.MessageReactionAdd, async (reaction, user, messageId, channelId, emoji, userId) => {\n if (emoji.name === '👍') {\n console.log(`User ${userId} voted yes on message ${messageId}`);\n const message = await reaction.fetchMessage();\n if (message) await message.react('✅');\n }\n});\n\nclient.on(Events.MessageReactionRemove, (reaction, user, messageId, channelId, emoji, userId) => {\n console.log(`User ${userId} removed ${emoji.name} from message ${messageId}`);\n});",
|
|
418
|
+
"language": "javascript"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"title": "Reaction Roles Example",
|
|
422
|
+
"description": "See examples/reaction-roles-bot.js for a full bot that assigns roles when users react to a message. Uses (reaction, user), Guild.fetchMember(), member.roles.add() (Discord.js parity), and guild.createRole() if you need to create roles programmatically. See the Roles guide for role CRUD.",
|
|
423
|
+
"discordJsCompat": "/docs/classes/GuildMemberRoleManager",
|
|
424
|
+
"code": "// Simplified reaction-roles logic\nclient.on(Events.MessageReactionAdd, async (reaction, user) => {\n if (!reaction.guildId || reaction.messageId !== rolesMessageId) return;\n const roleId = ROLE_EMOJI_MAP[reaction.emoji.name];\n if (!roleId) return;\n const guild = client.guilds.get(reaction.guildId);\n const member = await guild?.fetchMember(user.id);\n if (member && !member.roles.cache.has(roleId)) await member.roles.add(roleId);\n});",
|
|
425
|
+
"language": "javascript"
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"id": "webhooks",
|
|
431
|
+
"slug": "webhooks",
|
|
432
|
+
"title": "Webhooks",
|
|
433
|
+
"description": "A complete guide to Discord webhooks—sending messages without a gateway, creating, editing, and managing webhooks.",
|
|
434
|
+
"category": "webhooks",
|
|
435
|
+
"sections": [
|
|
436
|
+
{
|
|
437
|
+
"title": "What are Webhooks?",
|
|
438
|
+
"description": "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."
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"title": "Webhooks Without a Bot",
|
|
442
|
+
"description": "A Client with intents: 0 is enough. No need to connect to the gateway or handle events. Ideal for scripts or one-off sends.",
|
|
443
|
+
"code": "import { Client, Webhook } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nconst webhook = Webhook.fromToken(client, webhookId, webhookToken);\nawait webhook.send('Message from a script!');",
|
|
444
|
+
"language": "javascript"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"title": "Creating a Webhook",
|
|
448
|
+
"description": "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.",
|
|
449
|
+
"code": "import { Client } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nawait client.login(process.env.FLUXER_BOT_TOKEN);\n\nconst channel = client.channels.get(channelId);\nif (!channel?.createWebhook) throw new Error('Channel does not support webhooks');\n\nconst webhook = await channel.createWebhook({ name: 'My Webhook' });\nconsole.log(webhook.id, webhook.token); // Store token—it won't be returned when listing",
|
|
450
|
+
"language": "javascript"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"title": "Sending Messages",
|
|
454
|
+
"description": "Send text, embeds, or both. You can override the username and avatar for each message.",
|
|
455
|
+
"code": "import { Client, Webhook, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nconst webhook = Webhook.fromToken(client, webhookId, webhookToken);\n\nawait webhook.send({\n content: 'Hello from webhook!',\n embeds: [\n new EmbedBuilder()\n .setTitle('Webhook Message')\n .setColor(0x5865f2)\n .setTimestamp(),\n ],\n username: 'Custom Name',\n avatar_url: 'https://example.com/avatar.png',\n});",
|
|
456
|
+
"language": "javascript"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"title": "Simple text only",
|
|
460
|
+
"code": "await webhook.send('Plain text message');",
|
|
461
|
+
"language": "javascript"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"title": "Embeds without a title",
|
|
465
|
+
"description": "Embeds can use only a description—no title required. At least one of title, description, fields, or image is needed.",
|
|
466
|
+
"code": "await webhook.send({\n embeds: [\n new EmbedBuilder()\n .setDescription('Description-only embed works.')\n .setColor(0x5865f2),\n ],\n});",
|
|
467
|
+
"language": "javascript"
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"title": "Fetching & Listing Webhooks",
|
|
471
|
+
"description": "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.",
|
|
472
|
+
"code": "import { Client, Webhook } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nawait client.login(process.env.FLUXER_BOT_TOKEN);\n\n// Fetch single webhook (no token)\nconst webhook = await Webhook.fetch(client, webhookId);\n\n// List channel webhooks\nconst channel = client.channels.get(channelId);\nconst channelWebhooks = await channel?.fetchWebhooks() ?? [];\n\n// List guild webhooks\nconst guild = client.guilds.get(guildId);\nconst guildWebhooks = await guild?.fetchWebhooks() ?? [];",
|
|
473
|
+
"language": "javascript"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"title": "Editing a Webhook",
|
|
477
|
+
"description": "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.",
|
|
478
|
+
"code": "import { Client, Webhook } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nawait client.login(process.env.FLUXER_BOT_TOKEN);\n\n// With token (name and avatar only)\nconst webhook = Webhook.fromToken(client, webhookId, webhookToken);\nawait webhook.edit({ name: 'New Name', avatar: null });\n// avatar: null clears the webhook avatar\n\n// With bot auth (fetched webhook — can also move to another channel)\nconst fetched = await Webhook.fetch(client, webhookId);\nawait fetched.edit({\n name: 'Updated Name',\n channel_id: newChannelId, // move webhook to different channel\n});",
|
|
479
|
+
"language": "javascript"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"title": "Deleting a Webhook",
|
|
483
|
+
"code": "const webhook = await Webhook.fetch(client, webhookId);\nawait webhook.delete();",
|
|
484
|
+
"language": "javascript"
|
|
485
|
+
}
|
|
486
|
+
]
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"id": "webhook-attachments-embeds",
|
|
490
|
+
"slug": "webhook-attachments-embeds",
|
|
491
|
+
"title": "Webhook Attachments & Embeds",
|
|
492
|
+
"description": "Send embeds with or without a title, and attach files to webhook messages—same API as channel messages.",
|
|
493
|
+
"category": "webhooks",
|
|
494
|
+
"sections": [
|
|
495
|
+
{
|
|
496
|
+
"title": "Overview",
|
|
497
|
+
"description": "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."
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"title": "Embeds Without a Title",
|
|
501
|
+
"description": "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.",
|
|
502
|
+
"code": "import { Client, Webhook, EmbedBuilder } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\nconst webhook = Webhook.fromToken(client, webhookId, webhookToken);\n\n// Description only—no title\nawait webhook.send({\n embeds: [\n new EmbedBuilder()\n .setDescription('This embed has no title. Description-only works fine.')\n .setColor(0x5865f2)\n .setTimestamp(),\n ],\n});",
|
|
503
|
+
"language": "javascript"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"title": "Direct Attachments",
|
|
507
|
+
"description": "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.",
|
|
508
|
+
"code": "import { Client, Webhook } from '@fluxerjs/core';\nimport { readFileSync } from 'fs';\n\nconst client = new Client({ intents: 0 });\nconst webhook = Webhook.fromToken(client, webhookId, webhookToken);\n\nconst buffer = readFileSync('report.pdf');\nawait webhook.send({\n content: 'Report attached',\n files: [\n { name: 'report.pdf', data: buffer },\n { name: 'log.txt', data: new TextEncoder().encode('Log content'), filename: 'log-2025.txt' },\n ],\n});",
|
|
509
|
+
"language": "javascript"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"title": "Full Example: Embed + Files",
|
|
513
|
+
"description": "Combine content, description-only embed, and file attachments in a single webhook send.",
|
|
514
|
+
"code": "import { Client, Webhook, EmbedBuilder } from '@fluxerjs/core';\nimport { readFileSync } from 'fs';\n\nconst client = new Client({ intents: 0 });\nconst webhook = Webhook.fromToken(client, webhookId, webhookToken);\n\nawait webhook.send({\n content: 'Build completed',\n embeds: [\n new EmbedBuilder()\n .setDescription('Deploy succeeded. See attachment for logs.')\n .setColor(0x57f287)\n .setTimestamp(),\n ],\n files: [{ name: 'deploy.log', data: readFileSync('deploy.log') }],\n username: 'CI Bot',\n});",
|
|
515
|
+
"language": "javascript"
|
|
516
|
+
}
|
|
517
|
+
]
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"id": "voice",
|
|
521
|
+
"slug": "voice",
|
|
522
|
+
"title": "Voice",
|
|
523
|
+
"description": "Join voice channels and play audio with @fluxerjs/voice. Supports WebM/Opus streams—no FFmpeg required.",
|
|
524
|
+
"category": "voice",
|
|
525
|
+
"sections": [
|
|
526
|
+
{
|
|
527
|
+
"title": "Installation",
|
|
528
|
+
"description": "Add the voice package alongside the core library.",
|
|
529
|
+
"code": "pnpm add @fluxerjs/voice @fluxerjs/core",
|
|
530
|
+
"language": "bash"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"title": "Setup",
|
|
534
|
+
"description": "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.",
|
|
535
|
+
"code": "import { Client, Events, VoiceChannel } from '@fluxerjs/core';\nimport { getVoiceManager } from '@fluxerjs/voice';\n\nconst client = new Client({ intents: 0 });\ngetVoiceManager(client); // Must be before login\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
536
|
+
"language": "javascript"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"title": "Join a Voice Channel",
|
|
540
|
+
"description": "Get the user's voice channel with getVoiceChannelId, then join. The connection resolves when ready.",
|
|
541
|
+
"code": "const voiceManager = getVoiceManager(client);\nconst voiceChannelId = voiceManager.getVoiceChannelId(guildId, userId);\nif (!voiceChannelId) return; // User not in voice\n\nconst channel = client.channels.get(voiceChannelId);\nif (!(channel instanceof VoiceChannel)) return;\n\nconst connection = await voiceManager.join(channel);",
|
|
542
|
+
"language": "javascript"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"title": "Play Audio",
|
|
546
|
+
"description": "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.",
|
|
547
|
+
"code": "// URL (fetched and demuxed automatically)\nawait connection.play('https://example.com/audio.webm');\n\n// Or a Node.js ReadableStream of Opus\nawait connection.play(opusStream);",
|
|
548
|
+
"language": "javascript"
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"title": "Getting Stream URLs from YouTube",
|
|
552
|
+
"description": "Use youtube-dl-exec or yt-dlp to extract a WebM/Opus URL.",
|
|
553
|
+
"code": "import youtubedl from 'youtube-dl-exec';\n\nconst result = await youtubedl(videoUrl, {\n getUrl: true,\n f: 'bestaudio[ext=webm][acodec=opus]/bestaudio[ext=webm]/bestaudio',\n}, { timeout: 15000 });\n\nconst streamUrl = String(result ?? '').trim();\nawait connection.play(streamUrl);",
|
|
554
|
+
"language": "javascript"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
"title": "Volume Control",
|
|
558
|
+
"description": "LiveKitRtcConnection supports setVolume(0-200) and getVolume(). 100 = normal, 50 = half, 200 = double. Affects current and future playback.",
|
|
559
|
+
"code": "import { LiveKitRtcConnection } from '@fluxerjs/voice';\n\nif (connection instanceof LiveKitRtcConnection) {\n connection.setVolume(80); // 80% volume\n console.log('Current volume:', connection.getVolume());\n}",
|
|
560
|
+
"language": "javascript"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"title": "Stop and Leave",
|
|
564
|
+
"description": "Stop playback and disconnect. getConnection accepts channel ID or guild ID. leave(guildId) leaves all channels; leaveChannel(channelId) leaves a specific channel.",
|
|
565
|
+
"code": "// By channel ID (primary) or guild ID\nconst connection = voiceManager.getConnection(channelId) ?? voiceManager.getConnection(guildId);\nconnection?.stop();\nif (connection) voiceManager.leaveChannel(connection.channel.id);\n// Or leave all channels in the guild:\nvoiceManager.leave(guildId);",
|
|
566
|
+
"language": "javascript"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"title": "LiveKit and serverLeave",
|
|
570
|
+
"description": "If using LiveKit, the server may emit serverLeave. Listen and reconnect if needed.",
|
|
571
|
+
"code": "connection.on?.('serverLeave', async () => {\n try {\n const conn = await voiceManager.join(channel);\n await conn.play(streamUrl);\n } catch (e) {\n console.error('Auto-reconnect failed:', e);\n }\n});",
|
|
572
|
+
"language": "javascript"
|
|
573
|
+
}
|
|
574
|
+
]
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"id": "events",
|
|
578
|
+
"slug": "events",
|
|
579
|
+
"title": "Events",
|
|
580
|
+
"description": "Listen to gateway events with client.on. Handle messages, guild updates, voice state changes, and more.",
|
|
581
|
+
"category": "events",
|
|
582
|
+
"sections": [
|
|
583
|
+
{
|
|
584
|
+
"title": "Basic Usage",
|
|
585
|
+
"description": "Use client.on(Events.X, handler) to subscribe to events. Handlers receive event-specific payloads.",
|
|
586
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.Ready, () => {\n console.log('Bot is ready!');\n});\n\nclient.on(Events.MessageCreate, async (message) => {\n console.log(message.content);\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
587
|
+
"language": "javascript",
|
|
588
|
+
"tip": "client.events.X(handler) offers the same API with chaining and better autocomplete.",
|
|
589
|
+
"alternateCode": {
|
|
590
|
+
"label": "client.events",
|
|
591
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient\n .events.Ready(() => console.log('Bot is ready!'))\n .events.MessageCreate(async (message) => console.log(message.content));\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);"
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"title": "Common Events",
|
|
596
|
+
"description": "Essential events for most bots.",
|
|
597
|
+
"code": "// Bot finished loading\nclient.on(Events.Ready, () => {});\n\n// New message (DM or guild)\nclient.on(Events.MessageCreate, async (message) => {});\n\n// Reaction events\nclient.on(Events.MessageReactionAdd, (reaction, user, messageId, channelId, emoji, userId) => {});\nclient.on(Events.MessageReactionRemove, (reaction, user, messageId, channelId, emoji, userId) => {});\n\n// Guild joined/left/updated\nclient.on(Events.GuildCreate, (guild) => {});\nclient.on(Events.GuildDelete, (guild) => {});\n\n// Channel created/updated/deleted\nclient.on(Events.ChannelCreate, (channel) => {});\nclient.on(Events.ChannelDelete, (channel) => {});\n\n// Member joined/left/updated\nclient.on(Events.GuildMemberAdd, (member) => {});\nclient.on(Events.GuildMemberRemove, (member) => {});\n\n// Voice state changed (for @fluxerjs/voice)\nclient.on(Events.VoiceStateUpdate, (data) => {});\nclient.on(Events.VoiceServerUpdate, (data) => {});",
|
|
598
|
+
"language": "javascript"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
"title": "Reaction Events",
|
|
602
|
+
"description": "Listen for when users add or remove reactions. Handlers receive (reaction, user, messageId, channelId, emoji, userId). Use MessageReactionRemoveAll and MessageReactionRemoveEmoji for moderator actions.",
|
|
603
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageReactionAdd, (reaction, user, messageId, channelId, emoji, userId) => {\n const emojiStr = emoji.id ? `<:${emoji.name}:${emoji.id}>` : emoji.name;\n console.log(`User ${userId} reacted with ${emojiStr} on message ${messageId}`);\n\n // Filter for specific message (e.g. poll) or emoji\n if (emoji.name === '👍') {\n console.log('Someone voted yes!');\n }\n});\n\nclient.on(Events.MessageReactionRemove, (reaction, user, messageId, channelId, emoji, userId) => {\n console.log(`User ${userId} removed ${emoji.name} from message ${messageId}`);\n});\n\nclient.on(Events.MessageReactionRemoveAll, (data) => {\n console.log(`All reactions cleared from message ${data.message_id}`);\n});\n\nclient.on(Events.MessageReactionRemoveEmoji, (data) => {\n console.log(`All ${data.emoji.name} reactions removed from message ${data.message_id}`);\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
604
|
+
"language": "javascript"
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
"title": "Error Handling",
|
|
608
|
+
"code": "client.on(Events.Error, (err) => {\n console.error('Client error:', err);\n});",
|
|
609
|
+
"language": "javascript"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"title": "Gateway Dispatch Events Reference",
|
|
613
|
+
"description": "All events the Fluxer gateway can send. Use GatewayDispatchEvents from @fluxerjs/types for type-safe checks.",
|
|
614
|
+
"table": {
|
|
615
|
+
"headers": [
|
|
616
|
+
"Category",
|
|
617
|
+
"Events"
|
|
618
|
+
],
|
|
619
|
+
"codeColumns": [
|
|
620
|
+
1
|
|
621
|
+
],
|
|
622
|
+
"rows": [
|
|
623
|
+
[
|
|
624
|
+
"Connection & Session",
|
|
625
|
+
"Ready, Resumed, SessionsReplace"
|
|
626
|
+
],
|
|
627
|
+
[
|
|
628
|
+
"User",
|
|
629
|
+
"UserUpdate, UserSettingsUpdate, UserGuildSettingsUpdate, UserPinnedDmsUpdate, UserNoteUpdate, RecentMentionDelete"
|
|
630
|
+
],
|
|
631
|
+
[
|
|
632
|
+
"Saved Messages & Auth",
|
|
633
|
+
"SavedMessageCreate, SavedMessageDelete, AuthSessionChange"
|
|
634
|
+
],
|
|
635
|
+
[
|
|
636
|
+
"Presence",
|
|
637
|
+
"PresenceUpdate"
|
|
638
|
+
],
|
|
639
|
+
[
|
|
640
|
+
"Guild",
|
|
641
|
+
"GuildCreate, GuildUpdate, GuildDelete, GuildMemberAdd, GuildMemberUpdate, GuildMemberRemove, GuildMembersChunk, GuildMemberListUpdate, GuildSync"
|
|
642
|
+
],
|
|
643
|
+
[
|
|
644
|
+
"Roles",
|
|
645
|
+
"GuildRoleCreate, GuildRoleUpdate, GuildRoleUpdateBulk, GuildRoleDelete"
|
|
646
|
+
],
|
|
647
|
+
[
|
|
648
|
+
"Guild Assets",
|
|
649
|
+
"GuildEmojisUpdate, GuildStickersUpdate"
|
|
650
|
+
],
|
|
651
|
+
[
|
|
652
|
+
"Moderation",
|
|
653
|
+
"GuildBanAdd, GuildBanRemove"
|
|
654
|
+
],
|
|
655
|
+
[
|
|
656
|
+
"Channels",
|
|
657
|
+
"ChannelCreate, ChannelUpdate, ChannelUpdateBulk, ChannelDelete, ChannelRecipientAdd, ChannelRecipientRemove, ChannelPinsUpdate, ChannelPinsAck"
|
|
658
|
+
],
|
|
659
|
+
[
|
|
660
|
+
"Passive",
|
|
661
|
+
"PassiveUpdates"
|
|
662
|
+
],
|
|
663
|
+
[
|
|
664
|
+
"Invites",
|
|
665
|
+
"InviteCreate, InviteDelete"
|
|
666
|
+
],
|
|
667
|
+
[
|
|
668
|
+
"Messages",
|
|
669
|
+
"MessageCreate, MessageUpdate, MessageDelete, MessageDeleteBulk, MessageReactionAdd, MessageReactionRemove, MessageReactionRemoveAll, MessageReactionRemoveEmoji, MessageAck"
|
|
670
|
+
],
|
|
671
|
+
[
|
|
672
|
+
"Typing",
|
|
673
|
+
"TypingStart"
|
|
674
|
+
],
|
|
675
|
+
[
|
|
676
|
+
"Webhooks",
|
|
677
|
+
"WebhooksUpdate"
|
|
678
|
+
],
|
|
679
|
+
[
|
|
680
|
+
"Relationships",
|
|
681
|
+
"RelationshipAdd, RelationshipUpdate, RelationshipRemove"
|
|
682
|
+
],
|
|
683
|
+
[
|
|
684
|
+
"Voice",
|
|
685
|
+
"VoiceStateUpdate, VoiceServerUpdate"
|
|
686
|
+
],
|
|
687
|
+
[
|
|
688
|
+
"Calls",
|
|
689
|
+
"CallCreate, CallUpdate, CallDelete"
|
|
690
|
+
],
|
|
691
|
+
[
|
|
692
|
+
"Favorites",
|
|
693
|
+
"FavoriteMemeCreate, FavoriteMemeUpdate, FavoriteMemeDelete"
|
|
694
|
+
],
|
|
695
|
+
[
|
|
696
|
+
"SDK / Compatibility",
|
|
697
|
+
"InteractionCreate, GuildIntegrationsUpdate, GuildScheduledEventCreate, GuildScheduledEventUpdate, GuildScheduledEventDelete"
|
|
698
|
+
]
|
|
699
|
+
]
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
"title": "Event Payload Reference",
|
|
704
|
+
"description": "Payload structure for each event. Handler receives (data) or (message), (reaction, user, ...) etc. Types: Gateway*DispatchData from @fluxerjs/types.",
|
|
705
|
+
"table": {
|
|
706
|
+
"headers": [
|
|
707
|
+
"Event",
|
|
708
|
+
"Payload"
|
|
709
|
+
],
|
|
710
|
+
"codeColumns": [
|
|
711
|
+
0,
|
|
712
|
+
1
|
|
713
|
+
],
|
|
714
|
+
"rows": [
|
|
715
|
+
[
|
|
716
|
+
"READY",
|
|
717
|
+
"{ v, user, guilds, session_id, shard?, application: { id, flags } }"
|
|
718
|
+
],
|
|
719
|
+
[
|
|
720
|
+
"RESUMED",
|
|
721
|
+
"(no payload)"
|
|
722
|
+
],
|
|
723
|
+
[
|
|
724
|
+
"SESSIONS_REPLACE",
|
|
725
|
+
"Array of session objects"
|
|
726
|
+
],
|
|
727
|
+
[
|
|
728
|
+
"USER_UPDATE",
|
|
729
|
+
"APIUser — id, username, discriminator, global_name, avatar, etc."
|
|
730
|
+
],
|
|
731
|
+
[
|
|
732
|
+
"GUILD_CREATE",
|
|
733
|
+
"APIGuild — id, name, icon, owner_id, channels[], members[], roles[], ..."
|
|
734
|
+
],
|
|
735
|
+
[
|
|
736
|
+
"GUILD_UPDATE",
|
|
737
|
+
"APIGuild — full guild object"
|
|
738
|
+
],
|
|
739
|
+
[
|
|
740
|
+
"GUILD_DELETE",
|
|
741
|
+
"{ id, unavailable? }"
|
|
742
|
+
],
|
|
743
|
+
[
|
|
744
|
+
"GUILD_MEMBER_ADD",
|
|
745
|
+
"APIGuildMember & { guild_id } — user, roles, nick, joined_at, ..."
|
|
746
|
+
],
|
|
747
|
+
[
|
|
748
|
+
"GUILD_MEMBER_UPDATE",
|
|
749
|
+
"{ guild_id, roles, user, nick?, avatar?, joined_at?, ... }"
|
|
750
|
+
],
|
|
751
|
+
[
|
|
752
|
+
"GUILD_MEMBER_REMOVE",
|
|
753
|
+
"{ guild_id, user }"
|
|
754
|
+
],
|
|
755
|
+
[
|
|
756
|
+
"GUILD_MEMBERS_CHUNK",
|
|
757
|
+
"{ guild_id, members[], chunk_index, chunk_count, presences?, nonce? }"
|
|
758
|
+
],
|
|
759
|
+
[
|
|
760
|
+
"GUILD_MEMBER_LIST_UPDATE",
|
|
761
|
+
"{ guild_id, id, member_count, online_count, groups[], ops[] }"
|
|
762
|
+
],
|
|
763
|
+
[
|
|
764
|
+
"GUILD_ROLE_CREATE",
|
|
765
|
+
"{ guild_id, role: APIRole }"
|
|
766
|
+
],
|
|
767
|
+
[
|
|
768
|
+
"GUILD_ROLE_UPDATE",
|
|
769
|
+
"{ guild_id, role: APIRole }"
|
|
770
|
+
],
|
|
771
|
+
[
|
|
772
|
+
"GUILD_ROLE_UPDATE_BULK",
|
|
773
|
+
"{ guild_id, roles: APIRole[] }"
|
|
774
|
+
],
|
|
775
|
+
[
|
|
776
|
+
"GUILD_ROLE_DELETE",
|
|
777
|
+
"{ guild_id, role_id }"
|
|
778
|
+
],
|
|
779
|
+
[
|
|
780
|
+
"GUILD_EMOJIS_UPDATE",
|
|
781
|
+
"{ guild_id, emojis: APIEmoji[] }"
|
|
782
|
+
],
|
|
783
|
+
[
|
|
784
|
+
"GUILD_STICKERS_UPDATE",
|
|
785
|
+
"{ guild_id, stickers: APISticker[] }"
|
|
786
|
+
],
|
|
787
|
+
[
|
|
788
|
+
"GUILD_BAN_ADD",
|
|
789
|
+
"{ guild_id, user, reason? }"
|
|
790
|
+
],
|
|
791
|
+
[
|
|
792
|
+
"GUILD_BAN_REMOVE",
|
|
793
|
+
"{ guild_id, user }"
|
|
794
|
+
],
|
|
795
|
+
[
|
|
796
|
+
"CHANNEL_CREATE",
|
|
797
|
+
"APIChannel — id, name, type, guild_id?, parent_id, ..."
|
|
798
|
+
],
|
|
799
|
+
[
|
|
800
|
+
"CHANNEL_UPDATE",
|
|
801
|
+
"APIChannel"
|
|
802
|
+
],
|
|
803
|
+
[
|
|
804
|
+
"CHANNEL_UPDATE_BULK",
|
|
805
|
+
"{ channels: APIChannel[] }"
|
|
806
|
+
],
|
|
807
|
+
[
|
|
808
|
+
"CHANNEL_DELETE",
|
|
809
|
+
"APIChannel"
|
|
810
|
+
],
|
|
811
|
+
[
|
|
812
|
+
"CHANNEL_RECIPIENT_ADD",
|
|
813
|
+
"{ channel_id, user }"
|
|
814
|
+
],
|
|
815
|
+
[
|
|
816
|
+
"CHANNEL_RECIPIENT_REMOVE",
|
|
817
|
+
"{ channel_id, user }"
|
|
818
|
+
],
|
|
819
|
+
[
|
|
820
|
+
"CHANNEL_PINS_UPDATE",
|
|
821
|
+
"{ channel_id, guild_id?, last_pin_timestamp? }"
|
|
822
|
+
],
|
|
823
|
+
[
|
|
824
|
+
"CHANNEL_PINS_ACK",
|
|
825
|
+
"{ channel_id, last_pin_timestamp? }"
|
|
826
|
+
],
|
|
827
|
+
[
|
|
828
|
+
"INVITE_CREATE",
|
|
829
|
+
"APIInvite — code, guild, channel, inviter?, expires_at?, ..."
|
|
830
|
+
],
|
|
831
|
+
[
|
|
832
|
+
"INVITE_DELETE",
|
|
833
|
+
"{ code, channel_id, guild_id? }"
|
|
834
|
+
],
|
|
835
|
+
[
|
|
836
|
+
"MESSAGE_CREATE",
|
|
837
|
+
"APIMessage — id, channel_id, author, content, embeds, attachments, member?, ..."
|
|
838
|
+
],
|
|
839
|
+
[
|
|
840
|
+
"MESSAGE_UPDATE",
|
|
841
|
+
"APIMessage — partial (edited fields)"
|
|
842
|
+
],
|
|
843
|
+
[
|
|
844
|
+
"MESSAGE_DELETE",
|
|
845
|
+
"{ id, channel_id, guild_id?, content?, author_id? }"
|
|
846
|
+
],
|
|
847
|
+
[
|
|
848
|
+
"MESSAGE_DELETE_BULK",
|
|
849
|
+
"{ ids[], channel_id, guild_id? }"
|
|
850
|
+
],
|
|
851
|
+
[
|
|
852
|
+
"MESSAGE_REACTION_ADD",
|
|
853
|
+
"{ message_id, channel_id, user_id, guild_id?, emoji: { id, name, animated? } }"
|
|
854
|
+
],
|
|
855
|
+
[
|
|
856
|
+
"MESSAGE_REACTION_REMOVE",
|
|
857
|
+
"{ message_id, channel_id, user_id, guild_id?, emoji }"
|
|
858
|
+
],
|
|
859
|
+
[
|
|
860
|
+
"MESSAGE_REACTION_REMOVE_ALL",
|
|
861
|
+
"{ message_id, channel_id, guild_id? }"
|
|
862
|
+
],
|
|
863
|
+
[
|
|
864
|
+
"MESSAGE_REACTION_REMOVE_EMOJI",
|
|
865
|
+
"{ message_id, channel_id, guild_id?, emoji }"
|
|
866
|
+
],
|
|
867
|
+
[
|
|
868
|
+
"MESSAGE_ACK",
|
|
869
|
+
"{ message_id, channel_id } — read receipt"
|
|
870
|
+
],
|
|
871
|
+
[
|
|
872
|
+
"TYPING_START",
|
|
873
|
+
"{ channel_id, user_id, timestamp, guild_id?, member? }"
|
|
874
|
+
],
|
|
875
|
+
[
|
|
876
|
+
"VOICE_STATE_UPDATE",
|
|
877
|
+
"{ guild_id?, channel_id, user_id, member?, session_id, deaf?, mute?, ... }"
|
|
878
|
+
],
|
|
879
|
+
[
|
|
880
|
+
"VOICE_SERVER_UPDATE",
|
|
881
|
+
"{ token, guild_id, endpoint, connection_id? }"
|
|
882
|
+
],
|
|
883
|
+
[
|
|
884
|
+
"WEBHOOKS_UPDATE",
|
|
885
|
+
"{ guild_id, channel_id }"
|
|
886
|
+
],
|
|
887
|
+
[
|
|
888
|
+
"PRESENCE_UPDATE",
|
|
889
|
+
"{ user: { id }, guild_id?, status?, activities?, custom_status? }"
|
|
890
|
+
],
|
|
891
|
+
[
|
|
892
|
+
"GUILD_INTEGRATIONS_UPDATE",
|
|
893
|
+
"{ guild_id }"
|
|
894
|
+
],
|
|
895
|
+
[
|
|
896
|
+
"GUILD_SCHEDULED_EVENT_CREATE",
|
|
897
|
+
"{ guild_id, id }"
|
|
898
|
+
],
|
|
899
|
+
[
|
|
900
|
+
"GUILD_SCHEDULED_EVENT_UPDATE",
|
|
901
|
+
"{ guild_id, id }"
|
|
902
|
+
],
|
|
903
|
+
[
|
|
904
|
+
"GUILD_SCHEDULED_EVENT_DELETE",
|
|
905
|
+
"{ guild_id, id }"
|
|
906
|
+
],
|
|
907
|
+
[
|
|
908
|
+
"USER_NOTE_UPDATE",
|
|
909
|
+
"{ id, note? }"
|
|
910
|
+
],
|
|
911
|
+
[
|
|
912
|
+
"SAVED_MESSAGE_CREATE",
|
|
913
|
+
"APIMessage"
|
|
914
|
+
],
|
|
915
|
+
[
|
|
916
|
+
"SAVED_MESSAGE_DELETE",
|
|
917
|
+
"{ id }"
|
|
918
|
+
],
|
|
919
|
+
[
|
|
920
|
+
"RELATIONSHIP_ADD / UPDATE",
|
|
921
|
+
"{ id, type }"
|
|
922
|
+
],
|
|
923
|
+
[
|
|
924
|
+
"RELATIONSHIP_REMOVE",
|
|
925
|
+
"{ id }"
|
|
926
|
+
],
|
|
927
|
+
[
|
|
928
|
+
"CALL_CREATE / UPDATE / DELETE",
|
|
929
|
+
"{ id, channel_id, ... }"
|
|
930
|
+
],
|
|
931
|
+
[
|
|
932
|
+
"INTERACTION_CREATE",
|
|
933
|
+
"APIApplicationCommandInteraction"
|
|
934
|
+
]
|
|
935
|
+
]
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
]
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
"id": "permissions",
|
|
942
|
+
"slug": "permissions",
|
|
943
|
+
"title": "Permissions",
|
|
944
|
+
"description": "Check member permissions (guild-level and channel-specific), bot permissions via guild.members.me, owner override, and PermissionFlags.",
|
|
945
|
+
"category": "other",
|
|
946
|
+
"sections": [
|
|
947
|
+
{
|
|
948
|
+
"title": "Overview",
|
|
949
|
+
"description": "Use member.permissions for guild-level checks (roles only) and member.permissionsIn(channel) for channel-specific permissions (includes overwrites). The server owner always has all permissions."
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
"title": "Guild-level permissions",
|
|
953
|
+
"description": "member.permissions returns an object with has(permission). Use it for server-wide actions like ban, kick, manage roles.",
|
|
954
|
+
"code": "import { Client, Events, PermissionFlags } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nasync function getMemberPerms(message) {\n const guild = message.guild ?? await message.client.guilds.resolve(message.guildId);\n if (!guild) return null;\n const member = guild.members.get(message.author.id) ?? await guild.fetchMember(message.author.id);\n return member?.permissions ?? null;\n}\n\nclient.on(Events.MessageCreate, async (message) => {\n const perms = await getMemberPerms(message);\n if (!perms) return;\n\n if (perms.has(PermissionFlags.BanMembers)) {\n await message.reply('You can ban members.');\n }\n if (perms.has(PermissionFlags.Administrator)) {\n await message.reply('You have Administrator.');\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
955
|
+
"language": "javascript"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
"title": "Bot's own permissions (guild.members.me)",
|
|
959
|
+
"discordJsCompat": "/docs/classes/GuildMemberManager",
|
|
960
|
+
"description": "Use guild.members.me to get the bot's GuildMember. Returns null if not cached. Use guild.members.fetchMe() to load it. Discord.js parity.",
|
|
961
|
+
"code": "// Check if the bot can ban members in this guild\nconst guild = message.guild ?? await message.client.guilds.resolve(message.guildId);\nconst me = guild?.members.me ?? (guild ? await guild.members.fetchMe() : null);\nif (me?.permissions.has(PermissionFlags.BanMembers)) {\n await message.reply('I have Ban Members permission.');\n}",
|
|
962
|
+
"language": "javascript"
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
"title": "Editing the bot's guild profile (nickname)",
|
|
966
|
+
"description": "Use guild.members.me.edit({ nick }) to change the bot's nickname in that guild. Pass nick: null to clear and show the username. Requires Change Nickname permission (or bot has Manage Nicknames). See examples/ping-bot.js for a !setnick command.",
|
|
967
|
+
"code": "const guild = message.guild ?? await client.guilds.resolve(message.guildId);\nconst me = guild?.members.me ?? (guild ? await guild.members.fetchMe() : null);\nif (me) {\n await me.edit({ nick: 'My Custom Nick' });\n await message.reply('Nickname updated!');\n}\n// Clear nickname (show username)\nawait me.edit({ nick: null });",
|
|
968
|
+
"language": "javascript"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
"title": "Owner override",
|
|
972
|
+
"description": "The guild owner automatically receives all permissions regardless of roles. No need to give the owner a role with Administrator.",
|
|
973
|
+
"code": "// When the message author is the server owner:\nconst perms = member.permissions;\nperms.has(PermissionFlags.BanMembers); // true\nperms.has(PermissionFlags.ManageRoles); // true\nperms.has(PermissionFlags.Administrator); // true\n// ... all permission flags return true for the owner",
|
|
974
|
+
"language": "javascript"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
"title": "Channel-specific permissions",
|
|
978
|
+
"description": "member.permissionsIn(channel) applies channel overwrites. Use it when checking if a user can send messages, read history, or connect to voice in a specific channel.",
|
|
979
|
+
"code": "const channel = message.channel;\nif (channel?.isSendable?.()) {\n const perms = member.permissionsIn(channel);\n if (perms.has(PermissionFlags.SendMessages)) {\n await channel.send('You can send here!');\n }\n}",
|
|
980
|
+
"language": "javascript"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
"title": "Managing roles",
|
|
984
|
+
"description": "Create, fetch, edit, and delete roles with guild.createRole(), guild.fetchRoles(), guild.fetchRole(roleId), role.edit(), and role.delete(). Use resolvePermissionsToBitfield() for permission bitfields. See the Roles guide for full examples.",
|
|
985
|
+
"code": "// Create a role with specific permissions\nconst role = await guild.createRole({\n name: 'Mod',\n permissions: ['KickMembers', 'BanMembers', 'ManageMessages'],\n});\n\n// Add/remove roles from members\nawait guild.addRoleToMember(userId, roleId);\nawait guild.removeRoleFromMember(userId, roleId);",
|
|
986
|
+
"language": "javascript"
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
"title": "PermissionFlags reference",
|
|
990
|
+
"description": "Common flags: BanMembers, KickMembers, Administrator, ManageRoles, ManageChannels, ManageGuild, ViewAuditLog, ManageMessages, SendMessages, EmbedLinks, AttachFiles, ReadMessageHistory, MentionEveryone, Connect, Speak, MuteMembers, ModerateMembers, CreateExpressions, PinMessages, BypassSlowmode.",
|
|
991
|
+
"code": "import { PermissionFlags } from '@fluxerjs/core';\n\n// Check multiple\nconst canModerate = perms.has(PermissionFlags.BanMembers) || perms.has(PermissionFlags.Administrator);\n\n// List all permissions the user has\nconst names = Object.keys(PermissionFlags).filter((name) =>\n perms.has(PermissionFlags[name])\n);\nawait message.reply(`Your permissions: ${names.join(', ')}`);",
|
|
992
|
+
"language": "javascript"
|
|
993
|
+
}
|
|
994
|
+
]
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
"id": "moderation",
|
|
998
|
+
"slug": "moderation",
|
|
999
|
+
"title": "Moderation",
|
|
1000
|
+
"description": "Implement ban, kick, and unban commands. Check permissions first (see Permissions guide).",
|
|
1001
|
+
"category": "other",
|
|
1002
|
+
"sections": [
|
|
1003
|
+
{
|
|
1004
|
+
"title": "Overview",
|
|
1005
|
+
"description": "Use guild.ban(), guild.kick(), and guild.unban() for moderation. Always check member permissions before allowing moderation commands—see the Permissions guide."
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
"title": "Ban a member",
|
|
1009
|
+
"description": "guild.ban(userId, options) bans a user. Pass reason for the audit log. Requires BanMembers permission.",
|
|
1010
|
+
"code": "const userId = parseUserMention(target);\nif (userId) {\n await guild.ban(userId, { reason: rest.join(' ') || undefined });\n await message.reply(`Banned <@${userId}>.`);\n}",
|
|
1011
|
+
"language": "javascript"
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
"title": "Kick a member",
|
|
1015
|
+
"description": "guild.kick(userId, options) kicks a user from the guild. Pass reason for the audit log. Requires KickMembers permission.",
|
|
1016
|
+
"code": "const userId = parseUserMention(target);\nif (userId) {\n await guild.kick(userId, { reason: rest.join(' ') || undefined });\n await message.reply(`Kicked <@${userId}>.`);\n}",
|
|
1017
|
+
"language": "javascript"
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
"title": "Unban a user",
|
|
1021
|
+
"description": "guild.unban(userId, reason?) removes a ban. Requires BanMembers permission.",
|
|
1022
|
+
"code": "const userId = parseUserMention(target);\nif (userId) {\n await guild.unban(userId, rest.join(' ') || undefined);\n await message.reply(`Unbanned <@${userId}>.`);\n}",
|
|
1023
|
+
"language": "javascript"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
"title": "Full moderation example",
|
|
1027
|
+
"description": "See examples/moderation-bot.js for a complete bot with !ban, !kick, !unban, and !perms commands.",
|
|
1028
|
+
"code": "import { Client, Events, PermissionFlags, parseUserMention } from '@fluxerjs/core';\n\nconst PREFIX = '!';\nconst client = new Client({ intents: 0 });\n\nasync function getModeratorPerms(message) {\n const guild = message.guild ?? await message.client.guilds.resolve(message.guildId);\n if (!guild) return null;\n const member = guild.members.get(message.author.id);\n const resolved = member ?? await guild.fetchMember(message.author.id);\n return resolved?.permissions ?? null;\n}\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.author.bot || !message.content?.startsWith(PREFIX)) return;\n const [cmd, target, ...rest] = message.content.slice(PREFIX.length).trim().split(/\\s+/);\n const perms = await getModeratorPerms(message);\n if (!perms) return;\n\n const guild = message.guild ?? await message.client.guilds.resolve(message.guildId);\n if (!guild) return;\n\n if (cmd === 'ban' && (perms.has(PermissionFlags.BanMembers) || perms.has(PermissionFlags.Administrator))) {\n const userId = parseUserMention(target);\n if (userId) {\n await guild.ban(userId, { reason: rest.join(' ') || undefined });\n await message.reply(`Banned <@${userId}>.`);\n }\n }\n if (cmd === 'kick' && (perms.has(PermissionFlags.KickMembers) || perms.has(PermissionFlags.Administrator))) {\n const userId = parseUserMention(target);\n if (userId) {\n await guild.kick(userId, { reason: rest.join(' ') || undefined });\n await message.reply(`Kicked <@${userId}>.`);\n }\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
1029
|
+
"language": "javascript"
|
|
1030
|
+
}
|
|
1031
|
+
]
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
"id": "roles",
|
|
1035
|
+
"slug": "roles",
|
|
1036
|
+
"title": "Roles",
|
|
1037
|
+
"description": "Create, fetch, edit, and delete guild roles. Use PermissionFlags and resolvePermissionsToBitfield for permission bitfields.",
|
|
1038
|
+
"category": "channels",
|
|
1039
|
+
"sections": [
|
|
1040
|
+
{
|
|
1041
|
+
"title": "Overview",
|
|
1042
|
+
"description": "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."
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
"title": "Create a role",
|
|
1046
|
+
"description": "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.",
|
|
1047
|
+
"code": "import { Client, Events, PermissionFlags, resolvePermissionsToBitfield } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.content === '!createrole' && message.guildId) {\n const guild = client.guilds.get(message.guildId) ?? await client.guilds.resolve(message.guildId);\n if (!guild) return;\n\n const role = await guild.createRole({\n name: 'Moderator',\n permissions: ['BanMembers', 'KickMembers', 'ManageMessages'],\n color: 0x5865f2,\n hoist: true,\n mentionable: false,\n });\n await message.reply(`Created role ${role.name} (${role.id})`);\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
1048
|
+
"language": "javascript"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
"title": "Fetch roles",
|
|
1052
|
+
"description": "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 FluxerError with ROLE_NOT_FOUND on 404.",
|
|
1053
|
+
"code": "// Fetch all roles (updates guild.roles cache)\nconst roles = await guild.fetchRoles();\n\n// Fetch a single role by ID\nconst role = await guild.fetchRole(roleId);\nconsole.log(role.name, role.color);",
|
|
1054
|
+
"language": "javascript"
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
"title": "Edit a role",
|
|
1058
|
+
"description": "Use role.edit() to update a role. Pass any of name, permissions, color, hoist, mentionable, unicode_emoji, position, hoist_position. Permissions accept PermissionResolvable.",
|
|
1059
|
+
"code": "const role = guild.roles.get(roleId) ?? await guild.fetchRole(roleId);\nawait role.edit({\n name: 'Senior Mod',\n permissions: ['BanMembers', 'KickMembers', 'ManageMessages', 'ManageRoles'],\n color: 0x57f287,\n});",
|
|
1060
|
+
"language": "javascript"
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"title": "Delete a role",
|
|
1064
|
+
"description": "Use role.delete() to remove a role. The role is removed from guild.roles cache.",
|
|
1065
|
+
"code": "const role = guild.roles.get(roleId) ?? await guild.fetchRole(roleId);\nawait role.delete();\nawait message.reply('Role deleted.');",
|
|
1066
|
+
"language": "javascript"
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
"title": "Check role permissions",
|
|
1070
|
+
"description": "Use role.has(permission) to check if a role has a specific permission. Administrator implies all permissions.",
|
|
1071
|
+
"code": "import { PermissionFlags } from '@fluxerjs/core';\n\nif (role.has(PermissionFlags.BanMembers)) {\n await message.reply('This role can ban members.');\n}\nif (role.has('ManageChannels')) {\n await message.reply('This role can manage channels.');\n}",
|
|
1072
|
+
"language": "javascript"
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
"title": "Add/remove roles from members (member.roles)",
|
|
1076
|
+
"discordJsCompat": "/docs/classes/GuildMemberRoleManager",
|
|
1077
|
+
"description": "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.",
|
|
1078
|
+
"code": "// Discord.js parity: member.roles.add(), remove(), set()\nconst member = await guild.fetchMember(userId);\n\nawait member.roles.add(roleId); // Add a role\nawait member.roles.remove(roleId); // Remove a role\nawait member.roles.set(['id1', 'id2']); // Replace all roles\n\n// Check if member has a role\nif (member.roles.cache.has(roleId)) {\n await message.reply('Member already has this role.');\n}\n\n// Guild-level: when you only have user ID (no member fetch needed)\nawait guild.addRoleToMember(userId, roleId);\nawait guild.removeRoleFromMember(userId, roleId);",
|
|
1079
|
+
"language": "javascript"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
"title": "Permission bitfields for create/edit",
|
|
1083
|
+
"description": "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.",
|
|
1084
|
+
"code": "import { resolvePermissionsToBitfield, PermissionFlags } from '@fluxerjs/core';\n\n// Single permission by name\nresolvePermissionsToBitfield('SendMessages'); // \"2048\"\n\n// Array of permissions (OR'd together)\nresolvePermissionsToBitfield(['SendMessages', 'ViewChannel', 'ReadMessageHistory']);\n// Returns combined bitfield as string\n\n// From PermissionFlags enum\nresolvePermissionsToBitfield(PermissionFlags.BanMembers); // \"4\"",
|
|
1085
|
+
"language": "javascript"
|
|
1086
|
+
}
|
|
1087
|
+
]
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
"id": "prefix-commands",
|
|
1091
|
+
"slug": "prefix-commands",
|
|
1092
|
+
"title": "Prefix Commands",
|
|
1093
|
+
"description": "Handle !commands by listening to MessageCreate and parsing the content.",
|
|
1094
|
+
"category": "events",
|
|
1095
|
+
"sections": [
|
|
1096
|
+
{
|
|
1097
|
+
"title": "Basic Structure",
|
|
1098
|
+
"description": "Check for a prefix, split args, and dispatch to command handlers.",
|
|
1099
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst PREFIX = '!';\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (message.author.bot || !message.content) return;\n if (!message.content.startsWith(PREFIX)) return;\n\n const args = message.content.slice(PREFIX.length).trim().split(/\\s+/);\n const command = args.shift()?.toLowerCase();\n\n if (command === 'ping') {\n await message.reply('Pong!');\n }\n if (command === 'hello') {\n const name = args[0] ?? 'there';\n await message.reply(`Hello, ${name}!`);\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
1100
|
+
"language": "javascript"
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"title": "Guild-Only Commands",
|
|
1104
|
+
"code": "if (!message.guildId) {\n await message.reply('This command only works in a server.');\n return;\n}",
|
|
1105
|
+
"language": "javascript"
|
|
1106
|
+
}
|
|
1107
|
+
]
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
"id": "channels",
|
|
1111
|
+
"slug": "channels",
|
|
1112
|
+
"title": "Channels",
|
|
1113
|
+
"description": "Create and manage channels, roles, and invites. Covers guild.createChannel(), channel.edit(), channel.createInvite(), guild.createRole(), and more.",
|
|
1114
|
+
"category": "channels",
|
|
1115
|
+
"sections": [
|
|
1116
|
+
{
|
|
1117
|
+
"title": "Channels — Create",
|
|
1118
|
+
"description": "Use guild.createChannel() to create text (0), voice (2), category (4), or link (5) channels. Requires Manage Channels permission. Pass parent_id to put a channel under a category.",
|
|
1119
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (!message.guildId || message.content !== '!createchannel') return;\n const guild = client.guilds.get(message.guildId) ?? await client.guilds.resolve(message.guildId);\n if (!guild) return;\n\n // Text channel (0), voice (2), category (4), link (5)\n const textChannel = await guild.createChannel({\n type: 0,\n name: 'general',\n });\n\n // Category, then voice channel under it\n const category = await guild.createChannel({\n type: 4,\n name: 'Voice Chats',\n });\n const voiceChannel = await guild.createChannel({\n type: 2,\n name: 'Lounge',\n parent_id: category.id,\n bitrate: 64000,\n });\n\n await message.reply(`Created ${textChannel.name} and ${voiceChannel.name} in ${category.name}`);\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
1120
|
+
"language": "javascript"
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
"title": "Channels — Fetch and Edit",
|
|
1124
|
+
"description": "Use guild.fetchChannels() to load all guild channels. Use channel.edit() to rename, set topic, move to a category, set slowmode, or update permission overwrites.",
|
|
1125
|
+
"code": "const guild = client.guilds.get(guildId) ?? await client.guilds.resolve(guildId);\nif (!guild) return;\n\nconst channels = await guild.fetchChannels();\n\n// Edit a text channel\nconst channel = guild.channels.get(channelId);\nif (channel) {\n await channel.edit({\n name: 'renamed-channel',\n topic: 'New topic here',\n parent_id: categoryId, // Move under category\n rate_limit_per_user: 5, // 5 second slowmode\n nsfw: false,\n });\n}",
|
|
1126
|
+
"language": "javascript"
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
"title": "Channels — Delete and Reorder",
|
|
1130
|
+
"description": "Use channel.delete() to remove a channel. Use guild.setChannelPositions() to reorder channels or move them between categories.",
|
|
1131
|
+
"code": "// Delete channel (silent: true skips system message)\nawait channel.delete();\nawait channel.delete({ silent: true });\n\n// Reorder channels\nawait guild.setChannelPositions([\n { id: channelId1, position: 0 },\n { id: channelId2, position: 1, parent_id: categoryId },\n]);",
|
|
1132
|
+
"language": "javascript"
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
"title": "Channel Permission Overwrites",
|
|
1136
|
+
"description": "Use channel.editPermission() to add or update overwrites (type 0=role, 1=member). Use channel.deletePermission() to remove. Use resolvePermissionsToBitfield() for allow/deny bitfields.",
|
|
1137
|
+
"code": "import { resolvePermissionsToBitfield, PermissionFlags } from '@fluxerjs/core';\n\n// Deny SendMessages for a role (type 0=role, 1=member)\nawait channel.editPermission(roleId, {\n type: 0,\n deny: resolvePermissionsToBitfield(['SendMessages']),\n});\n\n// Allow ViewChannel for a specific member\nawait channel.editPermission(userId, {\n type: 1,\n allow: resolvePermissionsToBitfield([PermissionFlags.ViewChannel]),\n});\n\n// Remove overwrite\nawait channel.deletePermission(roleId);",
|
|
1138
|
+
"language": "javascript"
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
"title": "Roles — Quick Reference",
|
|
1142
|
+
"description": "Create roles with guild.createRole(), fetch with guild.fetchRoles() or guild.fetchRole(roleId). Add/remove with guild.addRoleToMember() / guild.removeRoleFromMember(). Reorder with guild.setRolePositions().",
|
|
1143
|
+
"code": "// See the Roles guide for full examples and permission bitfields.\nconst role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });\nawait guild.addRoleToMember(userId, role.id);\nawait guild.removeRoleFromMember(userId, role.id);\nawait guild.setRolePositions([{ id: role.id, position: 5 }]);",
|
|
1144
|
+
"language": "javascript",
|
|
1145
|
+
"tip": "See the Roles guide for full examples, permission bitfields, and role.edit() / role.delete()."
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
"title": "Invites",
|
|
1149
|
+
"description": "Use channel.createInvite() to create an invite. Use channel.fetchInvites() to list channel invites. Use invite.delete() to revoke. invite.url gives the full invite URL.",
|
|
1150
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (!message.content.startsWith('!invite') || !message.guildId) return;\n const channel = message.channel;\n if (!channel?.createInvite) return;\n\n if (message.content === '!invite') {\n const invite = await channel.createInvite({\n max_age: 86400, // 24 hours\n max_uses: 10,\n temporary: false,\n });\n await message.reply(`Invite: ${invite.url}`);\n }\n\n if (message.content === '!invitelist') {\n const invites = await channel.fetchInvites();\n const list = invites.map((i) => `${i.code} (${i.max_uses ?? '∞'} uses)`).join('\\n');\n await message.reply(list || 'No invites.');\n }\n\n if (message.content.startsWith('!inviterevoke ')) {\n const code = message.content.slice(13).trim();\n const invites = await channel.fetchInvites();\n const inv = invites.find((i) => i.code === code);\n if (inv) {\n await inv.delete();\n await message.reply('Invite revoked.');\n }\n }\n});\n\nawait client.login(process.env.FLUXER_BOT_TOKEN);",
|
|
1151
|
+
"language": "javascript"
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"title": "Quick Reference",
|
|
1155
|
+
"table": {
|
|
1156
|
+
"headers": [
|
|
1157
|
+
"API",
|
|
1158
|
+
"Method",
|
|
1159
|
+
"Purpose"
|
|
1160
|
+
],
|
|
1161
|
+
"codeColumns": [
|
|
1162
|
+
0,
|
|
1163
|
+
1
|
|
1164
|
+
],
|
|
1165
|
+
"rows": [
|
|
1166
|
+
[
|
|
1167
|
+
"Channels",
|
|
1168
|
+
"guild.createChannel()",
|
|
1169
|
+
"Create text, voice, category, or link channel"
|
|
1170
|
+
],
|
|
1171
|
+
[
|
|
1172
|
+
"Channels",
|
|
1173
|
+
"guild.fetchChannels()",
|
|
1174
|
+
"Fetch all guild channels"
|
|
1175
|
+
],
|
|
1176
|
+
[
|
|
1177
|
+
"Channels",
|
|
1178
|
+
"channel.edit()",
|
|
1179
|
+
"Rename, set topic, slowmode, parent, overwrites"
|
|
1180
|
+
],
|
|
1181
|
+
[
|
|
1182
|
+
"Channels",
|
|
1183
|
+
"channel.delete()",
|
|
1184
|
+
"Delete a channel"
|
|
1185
|
+
],
|
|
1186
|
+
[
|
|
1187
|
+
"Channels",
|
|
1188
|
+
"guild.setChannelPositions()",
|
|
1189
|
+
"Reorder or reparent channels"
|
|
1190
|
+
],
|
|
1191
|
+
[
|
|
1192
|
+
"Channels",
|
|
1193
|
+
"channel.editPermission()",
|
|
1194
|
+
"Add or update permission overwrite"
|
|
1195
|
+
],
|
|
1196
|
+
[
|
|
1197
|
+
"Channels",
|
|
1198
|
+
"channel.deletePermission()",
|
|
1199
|
+
"Remove permission overwrite"
|
|
1200
|
+
],
|
|
1201
|
+
[
|
|
1202
|
+
"Roles",
|
|
1203
|
+
"guild.createRole()",
|
|
1204
|
+
"Create a role"
|
|
1205
|
+
],
|
|
1206
|
+
[
|
|
1207
|
+
"Roles",
|
|
1208
|
+
"guild.addRoleToMember()",
|
|
1209
|
+
"Add role to member"
|
|
1210
|
+
],
|
|
1211
|
+
[
|
|
1212
|
+
"Roles",
|
|
1213
|
+
"guild.removeRoleFromMember()",
|
|
1214
|
+
"Remove role from member"
|
|
1215
|
+
],
|
|
1216
|
+
[
|
|
1217
|
+
"Invites",
|
|
1218
|
+
"channel.createInvite()",
|
|
1219
|
+
"Create invite with max_uses, max_age"
|
|
1220
|
+
],
|
|
1221
|
+
[
|
|
1222
|
+
"Invites",
|
|
1223
|
+
"channel.fetchInvites()",
|
|
1224
|
+
"List channel invites"
|
|
1225
|
+
],
|
|
1226
|
+
[
|
|
1227
|
+
"Invites",
|
|
1228
|
+
"invite.delete()",
|
|
1229
|
+
"Revoke invite"
|
|
1230
|
+
]
|
|
1231
|
+
]
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
]
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"id": "emojis",
|
|
1238
|
+
"slug": "emojis",
|
|
1239
|
+
"title": "Emojis & Stickers",
|
|
1240
|
+
"description": "Fetch, create, edit, and delete guild emojis and stickers. Use guild.fetchEmojis(), guild.createEmojisBulk(), and guild.createStickersBulk().",
|
|
1241
|
+
"category": "emojis",
|
|
1242
|
+
"sections": [
|
|
1243
|
+
{
|
|
1244
|
+
"title": "Fetch Emojis",
|
|
1245
|
+
"description": "Use guild.fetchEmojis() to get all emojis in a guild. Cached in guild.emojis. Use guild.fetchEmoji(emojiId) for a single emoji. Use emoji.delete() to remove an emoji (e.g. autocreated ones).",
|
|
1246
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\nclient.on(Events.MessageCreate, async (message) => {\n if (!message.guildId || message.content !== '!emojis') return;\n const guild = client.guilds.get(message.guildId) ?? await client.guilds.resolve(message.guildId);\n if (!guild) return;\n\n const emojis = await guild.fetchEmojis();\n const list = emojis.map((e) => `:${e.name}: (${e.id})`).join(', ');\n await message.reply(emojis.length ? list : 'No emojis.');\n\n // Or get from cache after fetching: guild.emojis.get(emojiId)\n});\n\n// Fetch single emoji by ID\nconst emoji = await guild.fetchEmoji(emojiId);\nawait emoji.delete();",
|
|
1247
|
+
"language": "javascript"
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
"title": "Create Emojis & Stickers",
|
|
1251
|
+
"description": "Use guild.createEmojisBulk() and guild.createStickersBulk() with base64 image data. Use emoji.edit() / emoji.delete() and sticker.edit() / sticker.delete() for individual updates.",
|
|
1252
|
+
"code": "import { Client, Events } from '@fluxerjs/core';\n\nconst client = new Client({ intents: 0 });\n\n// Create emoji from URL (fetch and convert to base64)\nasync function createEmojiFromUrl(guild, name, imageUrl) {\n const res = await fetch(imageUrl);\n const buf = await res.arrayBuffer();\n const base64 = Buffer.from(buf).toString('base64');\n const [emoji] = await guild.createEmojisBulk([{ name, image: base64 }]);\n return emoji;\n}\n\nclient.on(Events.MessageCreate, async (message) => {\n if (!message.guildId || !message.content.startsWith('!addemoji ')) return;\n const guild = client.guilds.get(message.guildId) ?? await client.guilds.resolve(message.guildId);\n if (!guild) return;\n\n const [_, name, url] = message.content.split(/\\s+/);\n if (!name || !url) return;\n const emoji = await createEmojiFromUrl(guild, name, url);\n await message.reply(`Created emoji :${emoji.name}:`);\n});\n\n// Bulk create stickers\nconst stickers = await guild.createStickersBulk([\n { name: 'cool', image: base64Image, description: 'A cool sticker' },\n]);\n\n// Edit and delete\nawait emoji.edit({ name: 'newname' });\nawait emoji.delete();",
|
|
1253
|
+
"language": "javascript"
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
"title": "Quick Reference",
|
|
1257
|
+
"table": {
|
|
1258
|
+
"headers": [
|
|
1259
|
+
"API",
|
|
1260
|
+
"Method",
|
|
1261
|
+
"Purpose"
|
|
1262
|
+
],
|
|
1263
|
+
"codeColumns": [
|
|
1264
|
+
0,
|
|
1265
|
+
1
|
|
1266
|
+
],
|
|
1267
|
+
"rows": [
|
|
1268
|
+
[
|
|
1269
|
+
"Emojis",
|
|
1270
|
+
"guild.fetchEmojis()",
|
|
1271
|
+
"Fetch all guild emojis (cached in guild.emojis)"
|
|
1272
|
+
],
|
|
1273
|
+
[
|
|
1274
|
+
"Emojis",
|
|
1275
|
+
"guild.fetchEmoji(emojiId)",
|
|
1276
|
+
"Fetch single emoji by ID"
|
|
1277
|
+
],
|
|
1278
|
+
[
|
|
1279
|
+
"Emojis",
|
|
1280
|
+
"guild.createEmojisBulk()",
|
|
1281
|
+
"Bulk create emojis (base64 image)"
|
|
1282
|
+
],
|
|
1283
|
+
[
|
|
1284
|
+
"Stickers",
|
|
1285
|
+
"guild.createStickersBulk()",
|
|
1286
|
+
"Bulk create stickers"
|
|
1287
|
+
]
|
|
1288
|
+
]
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
]
|
|
1292
|
+
}
|
|
1293
|
+
]
|