Skip to content
Written for developers. Just using FluxPlugs? Go to the user guide.

Public SDK reference

Import definePlugin and types from @fluxplugs/plugin-api. SDK_API_VERSION is 2. All services below are accessed through the PluginAPI passed to start.

PluginDefinition has manifest: { id }, start(api), and optional stop(). Start/stop can be synchronous or return a promise. definePlugin registers the definition inside the sandbox.

JsonValue is null, boolean, number, string, an array of JSON values, or an object of JSON values. DOM nodes, functions, and credentials cannot be passed through RPC.

Unless noted, service calls are asynchronous. Registration calls return Promise<() => void>; save the disposer for cleanup. Getters and theme snapshots return promises of their values.

API Result and behavior
pluginId Read-only string identity
logger.debug/info/warn/error(message, fields?) Synchronous log methods; fields are JSON-valued records
capabilities.has(capability) Synchronous boolean grant check
storage.get<T>(key) T or undefined
storage.set(key, value) / delete(key) Save/remove plugin-private JSON
storage.getSecret(key) String, or undefined when unset or no longer readable
storage.setSecret(key, value) / deleteSecret(key) Save/remove a secret, encrypted where the system has a keystore; setSecret resolves with { protection }
storage.secretProtection() “os”, “basic” or “none”: how secrets are kept on this system
settings.get<T>(key) / set(key, value) Read/write manifest-defined boolean/string/number values

Generic type parameters describe expected data; validate structured values at runtime. Never log secrets or signed URLs.

API Inputs and result
ui.registerPanel(panel) { id, title, body }; disposer
ui.registerAttachmentAction(action, onInvoke) { id, label, submenu? }; disposer
ui.openDialog(description, onSubmit) NativeDialog and a submit callback that returns an error message to keep the dialog open, or undefined to accept; values, or undefined on cancellation
ui.openView(description, onAction?) { title, kind: “dialog” or “panel”, actions? } and a callback for the view’s buttons; disposer
ui.setViewActions(actions) ViewAction[] replacing the open view’s buttons
ui.setOverlay(description, onAction?) Geometry, color, text, optional actionLabel; null removes overlay
ui.theme() Record of allowed CSS variables
ui.onThemeChange(handler) Theme snapshot callback; disposer
ui.pickEmoji() Fluxer’s emoji picker; the unicode character or name:id the user picks, or undefined
ui.notify(message) Display a text notice
ui.registerContextMenuItem(item, onInvoke) { id, label, targets, submenu?, only? } and ContextMenuTarget callback; disposer
ui.registerSettingsPage(page, handlers?) { title } and optional { onShow, onHide }; disposer

NativeDialog contains title, description, submitLabel, and sections. NativeSection has title, controls, optional repeatKey/maxRows. NativeControl has key, label, kind (text, url, number, textarea, checkbox or password), optional placeholder/maxLength/value. A ViewAction has id, label, and optional primary and disabled. A context menu item’s only is “self” or “others”. A settings page shows the plugin’s frame while open. See native UI and sandbox views.

API Inputs and result
styling.apply(rules) StyleRule[] with selector, declarations, optional imageHandle; disposer
inspection.subscribe(handler, interceptClicks?) InspectionEvent callback; disposer. Element text only with message_content
shortcuts.register(shortcut, handler) Shortcut string (with Ctrl, Alt or Meta, or a function key) and callback; disposer
clipboard.writeText(text) Bounded, interaction-associated write
images.load(url) ImageResource { handle, width, height }
images.url(handle) / release(handle) A data: URL of the PNG / release the owned resource
network.fetch(request, options?) NetworkRequest to a listed host or approved server, and an optional { signal }; NetworkResponse, without a user action
network.requestServer(origin) Asks the user to approve a server; true if they allow it. After a user action or on the plugin’s settings page
network.servers() The origins the user approved for the plugin
messages.sendEmbed(draft) Validated EmbedDraft to current channel, after a user action
messages.insertText(text) Text typed into the message box, never sent, after a user action
messages.reply(messageId, text, options?) Reply to a message on screen; { mention } pings its author. After a user action, or with automation
messages.react(messageId, emoji) Unicode emoji or name:id reaction on a message on screen. After a user action, or with automation
messages.recent(options?) { limit? }, 1 to 100; RecentMessage[] of the open conversation, oldest first. Needs message_content and a user action
commands.register(command, onRun) CommandDefinition { name, description, usage? } and a CommandInvocation callback; disposer
attachments.registerContextAction(action, onInvoke) Right-click action on the kinds given (files by default) and AttachmentContext callback; disposer
attachments.resolve(contextHandle) ResolvedAttachment { id, filename, size, url }
externalLinks.open(url) Authorized browser navigation
stickers.add({ attachment, name? }) Opens FluxPlugs’ Add sticker dialog for an image or GIF context; { guildId }, or null if the user closes it
badges.registerRoleBadgeProvider(provider, options?) RoleBadgeRequest callback returning RoleBadgeResult; disposer
decorations.registerProvider(options, provide, onAction?) DecorationRequest callback returning DecorationResult; disposer
decorations.refresh(keys?) Ask again about some or all places

NetworkRequest has url, optional method (GET or POST), headers, body and timeoutMs; NetworkResponse has status, optional contentType, and body as text. RecentMessage has id, authorId, authorName (with author_names), timestamp, text, flags, replyTo, and attachment and embed counts. CommandInvocation has name, input, channelId and guildId. EmbedDraft supports title, url, description, color, author, thumbnail, image, footer, timestamp, and fields. InspectionEvent includes kind, sanitized metadata, and geometry. RoleBadgeRequest carries a community’s roles; RoleBadgeResult maps role ids to badges, plus an optional owner style. BadgeProviderOptions has maxPerUser (1 to 5, default 1), surfaces (replies off by default, the rest on) and memberLookup (default true). DecorationProviderOptions lists surfaces: messageAccessory, messageHeader, memberRow. Follow each guide for context and resource restrictions.

API Inputs and result
navigation.current() RouteInfo { kind, guildId?, channelId? }
navigation.onChange(handler) RouteInfo callback, called at once and on every change; disposer
guildData.info(guildId?) GuildInfo { id, name, icon? }
guildData.roles(guildId?) GuildRoleInfo[], highest position first
guildData.channels(guildId?) GuildChannelInfo[] { id, name, type, parentId?, position }
guildData.onChange(handler) GuildDataChange { guildId, kind } callback; disposer
activity.current(options?) ActivityState { focused, visible, idle }
activity.onChange(handler, options?) ActivityState callback, called at once and on every change; disposer
voice.current() VoiceState { state, channelId?, guildId? }
voice.onChange(handler) VoiceState callback, called at once and on every change; disposer

ActivityOptions has idleAfterSeconds, 60 to 3600 (default 300). A VoiceState’s state is disconnected, connecting or connected.

See navigation and community data, activity and voice, right-click menus and the message box, commands, decorations and network requests.

patcher.register(hook, handler) receives { hook, value } and returns a disposer. The handler returns the new value, synchronously or asynchronously; for the hooks in PatchHookValues, TypeScript knows its type.

cleanup.push(
await api.patcher.register("client-info.lines", (event) => [
...event.value,
"My plugin is active",
]),
);

This requires patcher. The hooks are client-info.lines and badges.merge; see patch hooks. Handlers run in registration order; throwing, timed-out or refused results are skipped. This is not arbitrary function replacement.

The public SDK source contains exact TypeScript signatures and exported types. Use errors and limits alongside this reference.

FluxPlugs is an independent project, not affiliated with or endorsed by Fluxer.