@wolfstar/http-framework is a small Node.js HTTP server plus a
set of classes, called pieces, that the framework discovers on disk. This guide walks through the moving parts so you know
where each piece of your bot belongs.
Request Flow
Discord does not hold a connection to your bot. It sends every interaction as an HTTPSPOST to the interactions endpoint
you configured, and expects a reply to that same request.
commandRun, commandSuccess, commandError, commandFinish, and the
matching interactionHandler* and autocomplete* events), so cross-cutting concerns such as logging and error replies live
in listeners instead of being repeated in every command. Expected failures, such as a denied
precondition, go to the *Denied events instead of commandError.
Project Layout
A project scaffolded with@wolfstar/create-http-framework looks like this:
client.load() scans every store, imports each file, and
registers the exported classes. You never register a command by hand: creating the file is enough.
The scaffold generates
commands/ (and lib/, locales/, tests/ depending on your choices). Add interaction-handlers/ and listeners/ when
you need them. See Pieces below.Entry Point
src/main.ts wires the pieces together. It runs the setup imports first, creates the client, loads the stores, publishes
the command definitions, and starts the server:
/register imports, module augmentations, logger configuration —
must be imported before new Client(), because the client reads that state while it is constructed. See
Configuring the Client for how client.load() finds your stores.
Pieces
Everything your bot does is a piece: a class that extends a base type, lives in a store directory, and is loaded by the framework. The three you will use most:
Pieces are regular classes, which is what makes them easy to test in isolation and to reload without restarting the
process. Configure them with
@ApplyOptions and gate them with the Requires* decorators from
@wolfstar/decorators instead of writing constructors
and if checks. The Build a Command guide covers commands in depth.
Commands and the Registry
A command describes its Discord definition with@RegisterCommand, and the framework collects every definition in the
application-command registry. Pushing the registry is what makes commands appear in Discord:
Listeners
A listener subscribes to a client event. The most common use is turning errors into replies and log lines in one place:The Container
Pieces reach shared services throughcontainer instead of importing singletons or receiving them through constructors.
container.logger, the client, and the stores are available as soon as @wolfstar/http-framework is imported. Your own
services join them by augmenting the Container interface and assigning the value during setup, so a command can use
this.container.database with full type safety.
Extending the Bot
Optional capabilities are added as plugins, imported through a/register entry point during setup:
Plugins are released from the
wolfstar-project/plugins repository; the
Plugins guide explains how registration works.
Testing the Bot
Since a command is a plain class,@wolfstar/http-framework-test-utils can dispatch a typed interaction fixture at it and
assert on the reply, with no HTTP server and no Discord. Follow Testing Interactions to add
tests as the command set grows.
Public API
Every package exposes its supported API throughsrc/index.ts and explicit package.json export maps. The
API reference is generated from those entry points on every documentation build, so private
implementation files do not become accidental public contracts.