@bight-ts/core — Features
import { defineFeature, defineFeatures, type BightFeature,} from "@bight-ts/core";defineFeature(feature)
Section titled “defineFeature(feature)”Defines a feature module that bundles related commands, handlers, and plugins.
BightFeature<TServices>
Section titled “BightFeature<TServices>”| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Feature identifier (used in error messages for duplicate detection) |
commands | BotCommand[] | No | Slash commands belonging to this feature |
preconditions | BightPrecondition[] | No | Preconditions scoped to this feature |
buttonHandlers | ButtonHandler[] | No | Button interaction handlers |
modalHandlers | ModalHandler[] | No | Modal submission handlers |
selectMenuHandlers | SelectMenuHandler[] | No | Select menu handlers |
events | BotEvent[] | No | Discord client event listeners |
plugins | MaybeBightPlugin[] | No | Plugins scoped to this feature |
defineFeatures(features)
Section titled “defineFeatures(features)”Identity function for typing an array of features:
const features = defineFeatures([musicModule, moderationModule]);Behavior
Section titled “Behavior”- Features are explicitly registered via
loadFeaturesincreateBightApp()— they are not auto-discovered. - Commands and handlers from features merge into the app’s main registry during startup.
- Duplicate command names across features are detected and reported with the feature’s
namefor context.