Patch hooks
Declare patcher to transform values FluxPlugs is about to use. Each named hook carries a typed value, and every handler’s result is checked before it counts. Hooks are not a way to replace Fluxer’s code.
Reorder badges
Section titled “Reorder badges”cleanup.push( await api.patcher.register("badges.merge", ({ value }) => ({ ...value, badges: [...value.badges].sort((a, b) => a.pluginId === api.pluginId ? -1 : b.pluginId === api.pluginId ? 1 : 0, ), })),);| Hook | Value | What a handler may do |
|---|---|---|
| client-info.lines | The lines of the FluxPlugs client-info block | Return up to 8 strings of up to 120 characters; an empty list keeps the default |
| badges.merge | { surface, badges }: the badges about to be drawn next to one name or role | Reorder or drop them by key |
A badges.merge entry has key, label, icon, color, tooltip and pluginId, the plugin that added it. The value never says whose name the badges belong to. Only keys from the input count: badges can’t be added, restyled or credited to another plugin, and at most six are kept. The first draw uses the default order; the merged one follows a moment later and is remembered.
How handlers run
Section titled “How handlers run”Handlers for a hook run in registration order, each getting the previous one’s result, with one second each. A handler that throws, times out or returns something the hook doesn’t accept is skipped, and the value it was given carries on. Registering a hook that doesn’t exist fails with unknown_patch_hook:<hook>.
With TypeScript, api.patcher.register knows each hook’s value type.
