On This Page

Effect API

Import from @neontechspace/fluxerly/effect

Build Fluxer bots, send webhook messages and use OAuth with Effect

Use this entry point in applications that already use Effect

An Effect is a description of work, not a Promise that has already started. Calling an SDK method usually builds that description without making a request. Inside Effect.gen, yield* executes a description and returns its successful result. Effect.runPromise executes a complete program and returns a JavaScript Promise. Executing the same description again repeats its work, including remote writes

Effect.Effect<A, E, R> describes a successful value A, expected errors E and required services R. Expected errors, such as invalid operation input or an HTTP rejection, use Effect's error channel. Defects are unexpected faults, such as a throwing property getter or failed cleanup. Misuse is a defect too: Invalid client, router or registration options, including a missing createClient token, die with ConfigurationError, and a pure helper given invalid input throws its error, which becomes a defect inside an Effect. Interruption is Effect's cancellation mechanism. Cause can represent errors, defects and interruption together. Cancellation waits for SDK-owned cleanup, but cannot undo a request already sent to Fluxer

Scope is the cleanup lifetime required by client creation, subscriptions and collectors. Wrap a program in Effect.scoped to provide that lifetime and close its resources when the program ends. Keep a client and its listeners inside their scopes rather than returning handles after their scopes close. Other required services come from the caller's Effect program, including services used by handlers

The glossary defines terms such as guild, gateway, shard, gateway gap and REST

Stream values describe sequences. Requests and listeners start when the caller consumes the Stream. Methods returning plain values act immediately: The diagnostics and cache.clear methods, pure helpers such as format.userMention, permissions.calculate, and command router creation, registration and help

TypeScript
import { Effect } from "effect"
import { createClient } from "@neontechspace/fluxerly/effect"

export function sendOnce(token: string, channelId: string) {
    const program = Effect.scoped(
        Effect.gen(function* () {
            const client = yield* createClient({ token })
            return yield* client.messages.send(channelId, "Hello")
        }),
    )
    return Effect.runPromise(program)
}

This example sends through HTTP without connecting the gateway. The returned Promise settles after the scoped client finishes cleanup

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

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

    32 symbols

    createClient defineBot runBot FluxerClient Client BotEvents

  • Commands

    67 symbols

    CommandArgumentDescriptor CommandArgumentSchema CommandArgumentOptionalValue CommandContextHelpOptions BotCommandsOptions MemoryCooldownOptions

  • Emoji and Stickers

    12 symbols

    GuildEmoji GuildSticker ExpressionReference ExpressionMetadata EmojiCreate ExpressionBatch

  • Errors

    90 symbols

    describeError ConfigurationError FluxerlyError ClientClosedError PaginationError HelperError

  • Events and Collectors

    55 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 ClientCounters FailureReport LogCategory ClientDiagnostics

  • Messages

    90 symbols

    Message MessageCore MessageReference SelectedMessage MessageFields ReactionEmojiInput

  • OAuth

    14 symbols

    OAuthTokens OAuthAuthorizationInput OAuthCodeExchangeInput OAuthConfig OAuthConnection OAuthIdentity

  • Options

    20 symbols

    RequestOptions AuditedRequestOptions OperationSignal ClientOptions 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