On This Page

JavaScript & TypeScript

Import from @neontechspace/fluxerly

Build a Fluxer bot with JavaScript or TypeScript

Import from @neontechspace/fluxerly and call its methods directly

This default API also includes webhooks, OAuth and local helpers, without requiring an Effect runtime. Network and other I/O operations return ResultAsync, which starts when called, not when awaited. Await it to get a Result: If isErr() is true, read error for the expected failure, otherwise read value. Call orThrow to get the value and throw the error instead, and return a Result from a handler to report its failure. Methods returning AsyncIterable start work when a for await loop pulls its first item. Local work returns plain values: Creating clients and routers, registering handlers, cache lookups and pure helpers. Misuse of those, such as invalid options or a missing token, throws ConfigurationError or the helper's own error at once. Unexpected SDK or cleanup failures throw or reject with SdkDefect. Use await using or try/finally to release client resources even when work fails

The glossary defines terms such as guild, gateway, shard, frozen snapshot and uncertain write

Coding agents: read node_modules/@neontechspace/fluxerly/agents/AGENTS.md before writing code with this package

import { runBot } from "@neontechspace/fluxerly"

// A failed run is logged and sets process.exitCode, and Ctrl+C stops the bot cleanly, so the returned Result needs
// no further handling here
await runBot({
    token: process.env.FLUXER_BOT_TOKEN,
    commands: { prefix: "!", commands: { ping: { execute: ({ reply }) => reply("Pong!") } } },
})
import { runBot } from "@neontechspace/fluxerly"

// A failed run is logged and sets process.exitCode, and Ctrl+C stops the bot cleanly, so the returned Result needs
// no further handling here
await runBot({
    token: process.env.FLUXER_BOT_TOKEN,
    commands: { prefix: "!", commands: { ping: { execute: ({ reply }) => reply("Pong!") } } },
})
import { createClient, orThrow } from "@neontechspace/fluxerly"

await using client = createClient({ token: process.env.FLUXER_BOT_TOKEN })

client.on("messageCreate", (message) => message.content === "!ping" ? client.messages.reply(message, "Pong!") : undefined)

// Run connects, recovers and stays pending until the client ends, and await using shuts it down afterwards
orThrow(await client.run())
import { createClient, orThrow } from "@neontechspace/fluxerly"

await using client = createClient({ token: process.env.FLUXER_BOT_TOKEN })

client.on("messageCreate", (message) =>
    message.content === "!ping" ? client.messages.reply(message, "Pong!") : undefined,
)

// Run connects, recovers and stays pending until the client ends, and await using shuts it down afterwards
orThrow(await client.run())
import { permissionBits, colors, text } from "@neontechspace/fluxerly"

export function pureHelpersExample(bits, content) {
    return {
        required: permissionBits.from(["ManageRoles", "ManageMessages"]),
        missing: permissionBits.missing(bits, ["ManageRoles", "ManageMessages"]),
        inspection: permissionBits.inspect(bits),
        color: colors.parse("#ff8800"),
        chunks: text.split(content, { maxLength: 2_000 }),
    }
}
import { permissionBits, colors, text } from "@neontechspace/fluxerly"

export function pureHelpersExample(bits: bigint, content: string) {
    return {
        required: permissionBits.from(["ManageRoles", "ManageMessages"]),
        missing: permissionBits.missing(bits, ["ManageRoles", "ManageMessages"]),
        inspection: permissionBits.inspect(bits),
        color: colors.parse("#ff8800"),
        chunks: text.split(content, { maxLength: 2_000 }),
    }
}

Categories#

  • Builders and Formatting

    34 symbols

    EmbedBuilder MessageBuilder AssetUrlOptions CustomEmojiMarkup ColorInput Mention

  • Caching

    11 symbols

    ResourceCacheSettings CacheKind MessageCacheOptions CacheChange CacheEntriesOptions CacheObserverOptions

  • Channels

    65 symbols

    isThreadChannel GuildChannel GuildThreadChannel ForumTagInput GuildForumChannel GuildMediaChannel

  • Client and Lifecycle

    29 symbols

    createClient defineBot runBot Client ConnectionState BotOptions

  • Commands

    63 symbols

    CommandArgumentDescriptor CommandArgumentSchema CommandArgumentOptionalValue CommandContextHelpOptions MemoryCooldownOptions PrefixCommandGuard

  • Emoji and Stickers

    12 symbols

    GuildEmoji GuildSticker ExpressionReference ExpressionMetadata EmojiCreate ExpressionBatch

  • Errors

    94 symbols

    describeError orThrow CancelledError ConfigurationError FluxerlyError ClientClosedError

  • Events and Collectors

    56 symbols

    EventMap EventName EventBufferOptions MessageReaction HandlerOptions EventContext

  • Guilds and Members

    77 symbols

    GuildMember MemberReference Guild GuildListSummary UserIterationQuery DiscoveryApplication

  • Invites and Webhooks

    28 symbols

    createWebhookClient InviteMetadata Webhook IncomingWebhook ChannelFollowerWebhook Invite

  • Logging and Diagnostics

    21 symbols

    LogRecord LoggingOptions FailureReport ClientCounters LogCategory ClientDiagnostics

  • Messages

    91 symbols

    Message MessageCore MessageReference SelectedMessage MessageFields ReactionEmojiInput

  • OAuth

    14 symbols

    OAuthTokens OAuthAuthorizationInput OAuthCodeExchangeInput OAuthConfig OAuthConnection OAuthIdentity

  • Options

    21 symbols

    RequestOptions AuditedRequestOptions OperationSignal OperationOptions PaginationQuery InstanceOptions

  • Roles and Permissions

    23 symbols

    PermissionOverwrite GuildRole RoleReference PermissionTarget ChannelPermissions HierarchyHelpers

  • Sharding and Supervision

    25 symbols

    fileSessionStore SessionStore ShardState ShardingOptions SupervisorAssignment IdentifyCoordinator

  • Users and DMs

    9 symbols

    User DirectMessageChannel UserProfileFields DirectMessageGroupEdit DirectMessageLatestMessages UserProfile