definePlugin

definePlugin<S>(setup: (plugin: PluginContext<S>) => void)

Declares a plugin. setup runs once when the deployment loads and must be synchronous, because commands and handlers are collected at publish.

weeble.definePlugin<{ channel: string }>((plugin) => {
  plugin.on('MESSAGE_REACTION_ADD', async (reaction) => {
    await plugin.kv().increment(reaction.messageId);
  });
});

Outside an installed plugin, for example while testing in the editor, slug is dev and settings is empty.

Type parameters:

S – (extends PluginSettings)