SWAGcommands
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);
OptionTypeWhat it does
clientClientYour discord.js client; required
commandsDirstringNormal slash/message/both command files
subcommandsDirstringSubcommand root folders
contextMenusDirstringUser and message context-menu files
preconditionsDirstringReusable precondition classes
featuresDirstringStartup and recurring feature files
eventsEventsCustom event directory and optional folder filters
validationsValidationsCustom syntax validation directory
defaultPrefixstringFallback message prefix; defaults to !
testServersstring[]Guild IDs used by TestOnly and test deployment
botOwnersstring[]User IDs used by OwnerOnly
prefixStorePrefixStoreCustom guild prefix persistence
cooldownStoreCooldownStoreCustom cooldown persistence
onErrorcallbackRuntime structured-error reporting
onPreconditionFailurecallbackChoose 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.