Skip to content
Classcore/pluginv0.10.0

Plugin

Base class for a seedcord plugin. Extend it and implement init(). this.core is the running bot.

Your constructor takes the host first and passes it to super(). Add your own parameters after it. attach() types them at the call site.

abstract class Plugin<
    Opts extends PluginOptions = {},
    TCore extends CoreBase = CoreBase
>
    implements Initializeable, HmrAware

Member visibility

Filter class members by access level.

Showing members with Protected visibility and higher.

Opts

Where this plugin may attach, checked only at compile time.

Opts extends PluginOptions = {}

TCore

The Core each transport binds this.core to.

TCore extends CoreBase = CoreBase

core

The host, typed to the transport whose Plugin base this class extends.

protected core: TCore

logger

Logs under the plugin's class name, on the channel its attach key sets.

protected readonly logger: Logger

dispose()

Runs during teardown, in ShutdownPhase.Disconnect by default. seedcord skips it when init() has thrown.

When init() outlasts its timeout, seedcord calls this once that init() resolves, outside any shutdown phase. The process must still be alive for that call to happen.

public async dispose?(): Promise<void>

ready()

Runs in the Ready phase, after every attached plugin's init() has resolved. The other Ready tasks run alongside it, including the http server binding its port.

Override it when your work needs a logged-in client or a resolved application id.

public async ready?(): Promise<void>

registerCriticalFiles()

Registers critical file patterns that should trigger a full restart when changed in Dev HMR.

protected registerCriticalFiles(
    patterns: string[]
): void
Parameter: patterns

Glob patterns relative to the project root

rejectOptions()

Throws a SeedcordError that contains the plugin class name and the reason.

protected rejectOptions(reason: string): never
Parameter: reason

Why the options are invalid.