Messages, replies and reactions
Declare messages to send a validated embed to the open channel, reply to a message, or add a reaction, right after a user action in your plugin. Add ui to obtain explicit input and display errors, automation to reply and react without a click, and message_content to read the conversation’s recent messages.
Send after confirmation
Section titled “Send after confirmation”This api-example registers a composer action. Test validation and cancellation with a mock API; clicking Send in a real client creates a real message.
cleanup.push( await api.ui.registerAttachmentAction( { id: "send-embed", label: "Compose embed" }, async () => { const values = await api.ui.openDialog( { title: "Send an embed", description: "Sends to the channel currently open in Fluxer.", submitLabel: "Send", sections: [ { title: "Content", controls: [ { key: "description", label: "Description", kind: "textarea", maxLength: 4096, }, ], }, ], }, (values) => typeof values.description === "string" && values.description.trim() ? undefined : "Enter a description", ); if (!values || typeof values.description !== "string") return; try { await api.messages.sendEmbed({ description: values.description }); } catch { await api.ui.notify( "Could not send the embed. Check the active channel and try again.", ); } }, ),);Do not send from the validator: validation may run repeatedly, and cancellation must not send anything. Recheck instance lifetime if your callback performs additional asynchronous work.
Sending needs a recent user action in the plugin’s UI, here the dialog’s Send button. Send straight after the dialog closes: the action allows one send within 1.5 seconds, and a later or second send fails with user_gesture_required.
Embed data
Section titled “Embed data”EmbedDraft supports title, url, description, numeric color, author, thumbnail, image, footer, timestamp, and up to 25 fields. Each field has name, value, and optional inline. Every URL must be public HTTPS. Host validation remains authoritative.
Type instead of sending
Section titled “Type instead of sending”messages.insertText(text) puts text into the message box at the cursor without sending it, after the same kind of user action. See right-click menus and the message box.
Read recent messages
Section titled “Read recent messages”messages.recent(options?) returns the newest messages of the conversation the user has open, oldest first: limit is 1 to 100, 50 by default. FluxPlugs reads them from Fluxer’s API with the user’s account, in up to two pages of 50, so they include messages that aren’t on screen. It needs message_content (not messages), an open conversation, and a recent user action, which it uses up. A command is the natural place to call it:
cleanup.push( await api.commands.register( { name: "links", description: "Lists links from recent messages" }, async () => { try { const messages = await api.messages.recent({ limit: 100 }); const links = messages.flatMap( (message) => message.text.match(/https:\/\/\S+/g) ?? [], ); await api.ui.notify( links.length ? links.slice(-5).join("\n") : "No links found.", ); } catch (error) { const code = error instanceof Error ? error.message : "unknown"; await api.ui.notify("Could not read the conversation (" + code + ")"); } }, ),);Each RecentMessage has:
| Field | Value |
|---|---|
| id | The message id |
| authorId | The author’s user id |
| authorName | The author’s name, only with author_names |
| timestamp | When it was sent, as an ISO 8601 date |
| text | The text, up to 4000 characters |
| flags | self, bot, webhook, reply, system, edited, pinned and mentioned; pending is always false |
| replyTo | The id of the message it replies to, if any |
| attachments | How many files it has; their names and contents aren’t included |
| embeds | How many embeds it has |
authorName needs the author_names capability. It is the name Fluxer shows on screen, including nicknames, when the author has a message on screen; otherwise it’s the account’s display name or username. Without the capability, messages carry ids only. Decorations and right-click targets never include names, even with author_names.
| Error | Meaning |
|---|---|
user_gesture_required |
No recent user action, or it was already used |
channel_unavailable |
No conversation is open |
message_history_busy |
The plugin is already reading messages; wait for that call |
message_rate_limited[:seconds] |
Fluxer rate-limited the user; wait the seconds it gave |
message_history_failed[:status] |
Fluxer refused or the connection failed |
message_history_timeout |
Fluxer didn’t answer within 10 seconds |
Recent messages include other people’s words. Use them for what the user asked for, and if you send them to a server, say so first; see network privacy.
Reply and react
Section titled “Reply and react”messages.reply(messageId, text, options?) posts a Fluxer reply to a message shown in the open channel. The text is 1 to 2000 characters. It can’t ping anyone: mentions in it stay plain text. Pass { mention: true } to ping the author of the replied-to message.
messages.react(messageId, emoji) adds the user’s reaction to a message shown in the open channel. Use a unicode emoji such as "👍", or a custom emoji as "name:id".
Both need the same kind of user action as sendEmbed, and each action allows one call. A decoration button is a natural place for them: this api-example adds a thumbs-up button under messages and reacts when it’s clicked.
cleanup.push( await api.decorations.registerProvider( { surfaces: ["messageAccessory"] }, (request) => ({ decorations: request.anchors.flatMap((anchor) => anchor.kind === "message" && !anchor.flags.self ? [ { key: anchor.key, blocks: [ { kind: "button" as const, id: "thumbs-up", label: "👍" }, ], }, ] : [], ), }), async (action) => { if (action.anchor.kind !== "message") return; try { await api.messages.react(action.anchor.messageId, "👍"); } catch { await api.ui.notify("Could not add the reaction. Try again."); } }, ),);The message must be on screen in the open channel, and not still sending, failed or a system message; otherwise the call fails with message_not_found or message_not_actionable. When Fluxer rate-limits the user, it fails with message_rate_limited, followed by the seconds to wait when Fluxer says (message_rate_limited:5).
Acting without a click (automation)
Section titled “Acting without a click (automation)”With the automation capability, reply and react also work without a user action, so a plugin can answer messages on its own. The enable prompt warns the user that these are sent from their account, and that Fluxer can delete accounts it treats as automated (self-bots). Offer a click-based flow first, and keep automatic behavior off until the user turns it on.
Without a user action, FluxPlugs enforces these limits whatever the plugin does:
- The message must be someone else’s, and at most two minutes old (
automation_own_message,automation_message_too_old). - Each message gets at most one automated reply, and each emoji at most one automated reaction (
automation_repeated). - One automated call every 3 seconds, 10 a minute, and 3 a minute in any one channel (
automation_rate_limited).
sendEmbed, insertText, the clipboard and links still need a user action. Listener is the bundled example of rules that run on their own.
Channel and credentials
Section titled “Channel and credentials”The plugin cannot choose arbitrary channel IDs through these APIs: embeds go to the open channel, and replies and reactions to the channel of a message on screen. Authentication and origin handling remain in core, and credentials never enter the sandbox.
No bundled plugin sends embeds; the first example is the complete flow. Automated acceptance must use mocks or controlled fixtures and must not send to production channels.
FluxPlugs is an independent project, not affiliated with or endorsed by Fluxer.