Skip to content

@bight-ts/core — App Runtime

import {
createBightApp,
type CreateBightAppOptions,
type BightAppRuntime,
} from "@bight-ts/core";

Creates a Bight application instance. Returns a BightApp with start() and createRuntime() methods.

PropertyTypeRequiredDescription
loadRegistry() => BightRegistryYesReturns the command, handler, and precondition registry (typically via createFilesystemDiscovery)
createServices(client: Client) => TServicesYes*Factory for your app services. Mutually exclusive with createContext.
createLogger(client: Client) => BightLoggerNoCustom logger factory. Defaults to the built-in logger.
createContext(client: Client) => BightContext<TServices>NoAdvanced escape hatch — builds the full context manually. Cannot be used with createServices or createLogger.
clientOptionsClientOptionsNoDiscord.js client options (intents, etc). Ignored if createClient is provided.
createClient() => ClientNoCustom client factory. Overrides clientOptions.
loadFeatures() => BightFeature[]NoFeature modules to merge into the registry.
loadEvents() => BotEvent[]NoDiscord client event listeners.
loadPlugins() => MaybeBightPlugin[]NoPlugins to apply during initialization.
runtimeObjectNoRuntime policies (see below).
loginMessagestringNoCustom log message on login. Defaults to "Logging in to Discord."
PropertyTypeDescription
cooldownsCooldownOptionsGlobal cooldown configuration
environmentBightRuntimeEnvironmentRuntime environment settings (e.g, devOnly enforcement)
globalPreconditionsstring[]Names of preconditions to evaluate on every interaction
onDeniedBightDeniedHandlerGlobal fallback handler for precondition denials

Returned by createRuntime(). Contains all resolved runtime state.

PropertyTypeDescription
clientClientThe Discord.js client instance
registryBightRegistryResolved command and handler registry
contextBightContextThe context object passed to all handlers
eventsBotEvent[]All registered event listeners
pluginsAppliedPluginsApplied plugin state with lifecycle hooks
diagnosticsBightDiagnosticsHubThe diagnostics hub
start(token: string) => Promise<void>Connects to Discord

The context object passed into every command, interaction handler, and plugin hook.

PropertyTypeDescription
clientClientThe Discord.js client
loggerBightLoggerThe app logger
servicesTServicesYour app-owned services