Sharkord
Plugins

API Reference

The whole plugin SDK surface in one page.

Plugin SDK version 2. Everything here is experimental and can change between releases.

Module Exports

@sharkord/plugin-sdk (server):

ExportWhat it is
PluginContext, UnloadPluginContext, UpgradePluginContextThe context types passed to each lifecycle function
PluginModule, TUpgradeInfoThe shape of a plugin's server entry
TPluginContractThe contract both halves share
Permission, ChannelPermission, ChannelTypeEnums used by requires, ctx.permissions and ctx.channels
TConsumeOptions, TVoiceConsumerHandleVoice consumer types
PluginSlot, TPluginSlotPropsThe component slots enum, and what each one passes
FileSaveType, MessageSaveTypePayload discriminators for the hooks
PLUGIN_SDK_VERSIONThe SDK version this build targets
ServerEvent, EventPayloadsEvent names and payloads
TCommandArg, TInvokerContextCommand argument and invoker types
TPluginSettingDefinition, PluginSettingsSettings types
TCreateStreamOptions, TExternalStreamHandleVoice stream types
mediasoup typesRouter, Producer, PlainTransport, RtpParameters, and others, re-exported

@sharkord/plugin-sdk/client (browser):

ExportWhat it is
createCallActionTyped caller for your own actions
useCanUseAction, useCanUseCommandWhether this user may call one, for disabling UI
useStoreSelectorReads a slice of Sharkord's state
usePushReceives what ctx.push sent
useUserDataPer-user storage for the signed-in user
actionsSharkord's own client actions
TPluginComponentsMapBySlotId, TPluginTabs, TPluginStoreStateThe types your client entry exports and reads

Plugin Lifecycle

export const onLoad = async (ctx: PluginContext) => {};
export const onUnload = async (ctx: UnloadPluginContext) => {};
export const onUpgrade = async (ctx: UpgradePluginContext, info: TUpgradeInfo) => {};

onLoad is required. onUnload is optional today and warns when missing, and will be required in a future SDK version. onUpgrade runs before onLoad, only when the installed version differs from the last one that ran.

The unload context is a subset: path, dataPath, logger, voice, messages, ui, and the deprecated log aliases. Registration namespaces are absent, because unregistering is automatic. The upgrade context is smaller still: pluginId, path, dataPath and logger.

PluginContext

MemberNotes
pluginIdYour plugin's id
pathThe plugin folder. Rewritten on every update
dataPathDurable storage. Survives updates, removed with the plugin
logger.log / debug / errorWrites to the plugin log shown in the interface
log / debug / errorDeprecated aliases of the above
events.on / offon returns an unsubscribe. Events
commands.register(command)Commands
actions.register(action)Actions
settings.register(definitions)Async, returns { get, set }. Settings
messages.send / edit / delete / get / list / pin / unpin / react / unreactAsync. Messages. send and edit take previews
users.list / get / ban / unban / kickAsync. Data
roles.list / get / assign / removeAsync. Data
permissions.userCan / userCanInChannelAsync. Data
channels.list / get / create / update / deleteAsync. Data
categories.list / get / create / update / deleteAsync. Data
userData.get / set / deleteAsync, per user. Data
push.toUser / toUsers / toAllServer to client. Client SDK
hooks.onBeforeMessageSave / onBeforeFileSave / onBeforeChannelCreate / onBeforeVoiceJoin / onBeforeLoginHooks
http.register / get / post / patch / delete / optionsHTTP routes
voice.getRouter / getListenInfo / getState / getProducers / createStream / consumeVoice
ui.enable(requirements?) / disable()Whether your components are rendered

Limits and Defaults

ThingValue
onLoad, onUnload, onUpgrade timeout30 seconds
Command and action execution timeout30 seconds
Hook execution timeout30 seconds
Event handler timeout10 seconds
Command, action and user-data rate limit60 per minute per user (configurable)
HTTP route rate limit300 per minute per IP, shared by all plugin routes (configurable)
Commands per plugin100
Actions per plugin100
HTTP routes per plugin100
Push payload64 KB of JSON
Per-user data64 KB of JSON
Hook reject reason200 characters
Capability types an admin can restrictcommands, actions, components, HTTP routes
Messages returned by messages.list100
Voice consumers per pluginunlimited; closed on unload
Permission to run commands and actionsUSE_PLUGINS
Permission to install and toggle pluginsMANAGE_PLUGINS
Permission to change capability accessMANAGE_PLUGIN_PERMISSIONS

Manifest

{
  "id": "my-plugin",
  "name": "My Plugin",
  "author": "Me",
  "description": "Does something useful.",
  "homepage": "https://example.com",
  "logo": "https://example.com/logo.png",
  "sdkVersion": 2,
  "version": "0.0.1"
}

id, name, author, description, sdkVersion, and version are required. id must be lowercase letters, numbers, and dashes, at most 64 characters, and must match the folder name. version must be semver. homepage and logo must be HTTP(S) URLs when present.

Source of Truth

When an example here and the code disagree, the code wins:

On this page