modularise chat commands and add error handling for wrong commands

This commit is contained in:
Fernando Campione
2026-01-09 10:28:50 +00:00
parent 0f08522e56
commit ddcf67226f
8 changed files with 359 additions and 292 deletions
+25
View File
@@ -0,0 +1,25 @@
# Chat Commands
Chat commands are modular and located in `public/js/chat-commands/`.
## Adding a Command
1. Create `chat-commands/mycommand.js`:
```javascript
export const myCommand = {
description: "What it does",
execute: () => {
const output = document.getElementById("terminal-output");
// implementation
},
};
```
2. Import and register in `commands.js`:
```javascript
import { myCommand } from "./chat-commands/mycommand.js";
const actions = {
// ... existing commands
"/mycommand": myCommand,
};