Slashy is the first free and open-source Discord bot that lets you create custom slash commands easily. It's been active since 2022, and its code is publicly available.
Slashy's main purpose is to allow anyone, regardless of technical skill, to add commands to their Discord server.
Key Features
- Command Management: Admins/managers can add, edit, delete, and list commands. Full command editing is done via a modal and is reflected instantly.
- Usage Tracking: Command usages are tracked (visible to admins/managers or bot host via PostHog).
- Ephemeral Replies: Command replies can be set to be visible only to the person who runs the command.
- Role-Gated Commands: Commands can be restricted to specific roles (multi-select), with the default being everyone.
- Internationalization: Supports all Discord locales.
- Admin Endpoints: Functionality for limiting the number of commands per guild and banning guilds.
The publicly-hosted version can be added via the provided OAuth link. Self-hosting is also an option.
User Commands
The bot uses the base command /slashy for management:
- /slashy add: Opens a modal for adding a new command.
- /slashy list: Shows the server's custom commands (only visible to you).
- /slashy delete <name>: Deletes a command. Uses autocomplete.
- /slashy edit <name>: Edits a command. Uses autocomplete.
Note: Created commands become real slash commands on the guild. The replies honor the stored visibility flag (ephemeral/public).
Developer Information
Stack
- Entrypoint: Cloudflare Worker (src/worker.ts).
- Toolchain: Bun, deployed with Wrangler.
- Discord: Interactions only, with Ed25519 verification (utils/verify.ts).
- Database: Cloudflare D1 binding (DB) for commands and guild metadata.
- REST: Client (discord/rest-client.ts) for registering commands on the fly.
Interaction Flow
- worker.fetch verifies the signature and builds context.
- router handles Ping, Autocomplete, Modal Submit, /slashy subcommands, or dynamic commands.
- /slashy requests trigger ensureBaseCommand to keep the root command up to date.
- Modal Submission: Sanitizes input, enforces Manage Server permission and guild limits, saves to D1, registers/patches the guild command, and replies ephemerally.
- Dynamic Command Handler: Fetches the command row, increments uses, applies placeholders, and replies as public or ephemeral based on the command settings. PostHog (if enabled) captures lifecycle events.
Persistence (D1 Tables)
- commands: Stores reply, description, ephemeral status (0/1), allowed_roles (JSON array), uses, and timestamps.
- guilds: Stores banned status and max_commands (default 50, can be overridden by MAX_COMMANDS environment variable).
Self-Hosting (Summary)
- Install Bun and Wrangler.
- Create a Cloudflare D1 database and bind it as DB.
- Set Discord app secrets: DISCORD_TOKEN, DISCORD_APP_ID, DISCORD_PUBLIC_KEY.
- Apply the DB schema: wrangler d1 migrations apply slashy.
- Set (or retrieve from logs) the SLASHY_SECRET for admin access.
- Register the base command: curl -H "Authorization: Bearer $SLASHY_SECRET" https://your-worker/admin/register-base.
- Use bun dev -- --remote for development or bun run deploy for deployment.
Slashy is licensed under GPL-3.0.