Skip to content

@bight-ts/core — Features

import {
defineFeature,
defineFeatures,
type BightFeature,
} from "@bight-ts/core";

Defines a feature module that bundles related commands, handlers, and plugins.

PropertyTypeRequiredDescription
namestringYesFeature identifier (used in error messages for duplicate detection)
commandsBotCommand[]NoSlash commands belonging to this feature
preconditionsBightPrecondition[]NoPreconditions scoped to this feature
buttonHandlersButtonHandler[]NoButton interaction handlers
modalHandlersModalHandler[]NoModal submission handlers
selectMenuHandlersSelectMenuHandler[]NoSelect menu handlers
eventsBotEvent[]NoDiscord client event listeners
pluginsMaybeBightPlugin[]NoPlugins scoped to this feature

Identity function for typing an array of features:

const features = defineFeatures([musicModule, moderationModule]);
  • Features are explicitly registered via loadFeatures in createBightApp() — 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 name for context.