mirror of
https://github.com/lklynet/hypermind.git
synced 2026-05-12 22:01:11 +00:00
modularise chat commands and add error handling for wrong commands
This commit is contained in:
@@ -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,
|
||||
};
|
||||
Reference in New Issue
Block a user