mirror of
https://github.com/arthur-pbty/flint.git
synced 2026-08-01 20:29:03 +02:00
feat: implement command definition, registration, and execution framework
- Add `defineCommand` function to validate and normalize command inputs. - Introduce `deployApplicationCommands` for deploying slash commands to Discord. - Create `CommandRegistry` class for managing command registration and retrieval. - Implement `buildSlashPayload` to construct slash command payloads with localization support. - Add usage utilities for prefix and slash commands. - Develop `CommandExecutor` to handle command execution with permission checks and cooldown management. - Create member message rendering service for welcome and leave messages with customizable templates. - Introduce presence template variables for dynamic bot status updates. - Implement template variable utilities for rendering and extracting variables from strings.
This commit is contained in:
@@ -79,13 +79,13 @@ An example with two bot services is available in `docker-compose.multi-bot.examp
|
||||
|
||||
## Architecture
|
||||
|
||||
- `src/framework/types/command.ts`: strict command schema
|
||||
- `src/framework/commands/defineCommand.ts`: default command completion
|
||||
- `src/framework/commands/registry.ts`: trigger/name mapping generated from i18n dictionaries
|
||||
- `src/framework/commands/argParser.ts`: prefix/slash args parsing from schema
|
||||
- `src/framework/execution/CommandExecutor.ts`: unified pipeline (permissions/cooldown/execute)
|
||||
- `src/framework/handlers/prefixHandler.ts`: prefix entrypoint
|
||||
- `src/framework/handlers/slashHandler.ts`: slash entrypoint
|
||||
- `src/types/command.ts`: strict command schema
|
||||
- `src/core/commands/defineCommand.ts`: default command completion
|
||||
- `src/core/commands/registry.ts`: trigger/name mapping generated from i18n dictionaries
|
||||
- `src/core/commands/argParser.ts`: prefix/slash args parsing from schema
|
||||
- `src/core/execution/CommandExecutor.ts`: unified pipeline (permissions/cooldown/execute)
|
||||
- `src/handlers/prefixHandler.ts`: prefix entrypoint
|
||||
- `src/handlers/slashHandler.ts`: slash entrypoint
|
||||
- `src/database/presence/presenceStore.ts`: PostgreSQL presence storage
|
||||
- `src/types/presenceTypes.ts`: shared presence types/validation
|
||||
- `src/i18n/*.json`: external i18n dictionaries
|
||||
@@ -102,6 +102,6 @@ An example with two bot services is available in `docker-compose.multi-bot.examp
|
||||
## Adding A Command
|
||||
|
||||
1. Create a command object in `src/commands/...`
|
||||
2. Follow the schema in `src/framework/types/command.ts`
|
||||
2. Follow the schema in `src/types/command.ts`
|
||||
3. Add command to `src/commands/index.ts`
|
||||
4. If `AUTO_DEPLOY_SLASH=true`, restart the bot to sync slash commands automatically
|
||||
|
||||
Reference in New Issue
Block a user