SWAGcommands
Commands

Command types

Choose slash, message, both, subcommands, or a context menu.

There isn't one correct shape for every bot. SWAGcommands gives you a few ways in, and the type value says where a normal command can run.

TypeMessage prefixSlash commandNeeds deployment
CommandType.SLASHNoYesYes
CommandType.LEGACYYesNoNo
CommandType.BOTHYesYesFor the slash side

“Legacy” is the enum name for a message command, not a version of these docs. A normal command is a default-exported object in commandsDir; its filename becomes the name. Add description for slash-capable commands.

import { CommandType } from "swagcommands";
import type { CommandObject } from "swagcommands";

const ping = {
  type: CommandType.SLASH,
  description: "See if I'm awake",
  callback: () => "Pong!",
} satisfies CommandObject;

export default ping;

Before the callback runs

SWAGcommands resolves preconditions during loading. At invocation time it checks them, commits any stateful checks (such as cooldowns), optionally defers the response, calls your callback, and sends the value you return. You can return undefined when you already replied yourself.

A command's init(client, instance) runs while definitions load. It is handy for command-specific setup; if it throws, initialization fails. For periodic work or cleanup, use a feature.

On this page