Documentation
¶
Overview ¶
Package module defines the Module interface — a compile-time unit that bundles related Commands, Component and Modal Routes, and Event listeners, with optional Setup and Teardown hooks. Modules are constructed by the bot author, who injects dependencies as struct fields; the framework provides no dependency container. Implemented in a later phase. See ADR 0003 and SPEC §2.6.
Package module defines the Module interface — a compile-time unit that bundles related Commands, Component and Modal Routes, and Event listeners, with optional Setup and Teardown lifecycle hooks. Modules are constructed by the bot author, who injects dependencies as struct fields; the framework provides no dependency container. See ADR 0003 and SPEC §2.6.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module interface {
// Register declares the module's commands, component routes, modal routes, and
// autocomplete handlers on the router. Called once at bot startup before Setup.
Register(r *router.Router)
// Listeners returns the gateway event listeners this module wants subscribed.
// May return nil or an empty slice if the module has no listeners.
Listeners() []event.Listener
// Setup is called after the gateway is open and all modules have been registered,
// before the bot blocks. Modules should perform startup tasks (e.g. populate caches,
// open connections) here. Setup is called in module registration order.
// A non-nil error halts startup.
Setup(ctx context.Context) error
// Teardown is called when the bot is shutting down (ctx cancelled), in reverse
// module registration order. Modules should release resources here.
// All modules' Teardown is called even if an earlier Teardown returns an error.
Teardown(ctx context.Context) error
}
Module is the extension point for grouping related commands, component/modal routes, and gateway event listeners. Each method is called by the Bot at the appropriate lifecycle point.
Modules are plain structs constructed by the bot author with dependencies as fields. The framework does not provide a dependency container. See ADR 0003 and SPEC §2.6.