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.
Make a bot
Install, write ping, and get it into your server.
Choose a command
Slash, message, both, subcommands, or context menus.
Guard a command
Permissions, owners, custom checks, and cooldowns.
Find the API
Options, callback usage, instance methods, and stores.
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
- New here? Read Quick start, then Application command deployment.
- Building commands? Start with Command types and Responses.
- Customizing behavior? Look at Preconditions, Events, and Features.
- Looking for an exact shape? The reference has the exported contracts and instance methods.
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.