API reference
Configuration
Every option accepted by SWAG.create().
SWAG.create(options) is the entry point. It returns a fully initialized SWAGCommands instance or rejects with InitializationError. Only client is required; add the folders your bot uses.
import SWAG from "swagcommands";
import type { Options } from "swagcommands";
const options: Options = {
client,
commandsDir: "./dist/commands",
defaultPrefix: "!",
};
const swag = await SWAG.create(options);| Option | Type | What it does |
|---|---|---|
client | Client | Your discord.js client; required |
commandsDir | string | Normal slash/message/both command files |
subcommandsDir | string | Subcommand root folders |
contextMenusDir | string | User and message context-menu files |
preconditionsDir | string | Reusable precondition classes |
featuresDir | string | Startup and recurring feature files |
events | Events | Custom event directory and optional folder filters |
validations | Validations | Custom syntax validation directory |
defaultPrefix | string | Fallback message prefix; defaults to ! |
testServers | string[] | Guild IDs used by TestOnly and test deployment |
botOwners | string[] | User IDs used by OwnerOnly |
prefixStore | PrefixStore | Custom guild prefix persistence |
cooldownStore | CooldownStore | Custom cooldown persistence |
onError | callback | Runtime structured-error reporting |
onPreconditionFailure | callback | Choose responses for denied commands |
events has an optional dir plus event-name keys for filters; validations currently has syntax?: string. If no store is supplied, SWAGcommands uses in-memory stores. Explicit botOwners is the reliable choice for owner checks.
Paths are used at runtime and relative to the process working directory. For compiled TypeScript, point them at emitted .js files. See Files and folders.