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, yield* executes a description and returns its successful result.
Effect executes a complete program and returns a JavaScript Promise.
Executing the same description again repeats its work, including remote writes
Effect 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 create token,
die with Configuration, 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 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 methods, pure helpers such as format,
permissions, and command router creation, registration and help
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_ before writing code with this package
Categories#
- Builders and Formatting
34 symbols
EmbedBuilder MessageBuilder AssetUrl Options CustomEmoji Markup ColorInput Mention - Caching
11 symbols
ResourceCache Settings CacheKind MessageCache Options CacheChange CacheEntries Options CacheObserver Options - Channels
65 symbols
isThread Channel GuildChannel GuildThread Channel ForumTag Input GuildForum Channel GuildMedia Channel - Client and Lifecycle
32 symbols
createClient defineBot runBot FluxerClient ClientBotEvents - Commands
67 symbols
CommandArgument Descriptor CommandArgument Schema CommandArgument Optional Value CommandContext Help Options BotCommands Options MemoryCooldown Options - Emoji and Stickers
12 symbols
GuildEmoji GuildSticker ExpressionReference ExpressionMetadata EmojiCreate ExpressionBatch - Errors
90 symbols
describeError ConfigurationError FluxerlyError ClientClosed Error PaginationError HelperError - Events and Collectors
55 symbols
EventMap EventName EventBuffer Options MessageReaction HandlerOptions EventContext - Guilds and Members
77 symbols
GuildMember MemberReference GuildGuildList Summary UserIteration Query DiscoveryApplication - Invites and Webhooks
28 symbols
createWebhook Client InviteMetadata WebhookIncomingWebhook ChannelFollower Webhook Invite - Logging and Diagnostics
21 symbols
LogRecord LoggingOptions ClientCounters FailureReport LogCategory ClientDiagnostics - Messages
90 symbols
MessageMessageCore MessageReference SelectedMessage MessageFields ReactionEmoji Input - OAuth
14 symbols
OAuthTokens OAuthAuthorization Input OAuthCode Exchange Input OAuthConfig OAuthConnection OAuthIdentity - Options
20 symbols
RequestOptions AuditedRequest Options OperationSignal ClientOptions PaginationQuery InstanceOptions - Roles and Permissions
23 symbols
PermissionOverwrite GuildRole RoleReference PermissionTarget ChannelPermissions HierarchyHelpers - Sharding and Supervision
25 symbols
fileSession Store SessionStore ShardState ShardingOptions SupervisorAssignment IdentifyCoordinator - Users and DMs
9 symbols
UserDirectMessage Channel UserProfile Fields DirectMessage Group Edit DirectMessage Latest Messages UserProfile