SWAGcommands

SWAGcommands

Documentation for SWAGcommands v2.

SWAGcommands is a file-based command handler for discord.js. Put a command in a file, point the framework at its directory, and get on with building the bot. It handles slash commands, message commands, subcommands, context menus, events, preconditions, cooldowns, and background features.

These docs cover the current v2 API as a whole. If you are starting from an empty folder, the quick start gets a bot online. If you already have one, jump straight to the bit you need.

How a SWAGcommands bot is organized

SWAG.create() loads your files and wires the Discord event listeners. You log in with your own discord.js Client, then explicitly deploy application commands when you want Discord's command list to match your files. Message commands need no deployment; they use your configured prefix.

src/
├── index.ts
├── commands/
│   ├── ping.ts
│   └── echo.ts
├── subcommands/
│   └── admin/
│       ├── index.ts
│       └── status.ts
├── context-menus/
│   └── User Information.ts
├── preconditions/
├── events/
└── features/

The directories are optional. Add only the ones your bot uses. The loader reads runtime .js files (and .ts files in a runtime that can load them), so compiled TypeScript apps should point at their emitted JavaScript folders.

Pick a path

About the project

SWAGcommands started as a package I made mostly for my own bots, so it’s a little opinionated about how they should be organized. Contributions and feature requests are always welcome.

On this page