Skip to content

Commit 4cac8a7

Browse files
committed
chore: merge
2 parents 106be2d + 5dfcdb3 commit 4cac8a7

3 files changed

Lines changed: 1415 additions & 17 deletions

File tree

src/commands/ai.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { Message } from "../types/message";
22
import log from "../components/utils/log";
33
import agentHandler from "../components/ai/agentHandler";
44
import { greetings } from "../components/utils/data";
5-
import { commands } from "../components/utils/cmd/loader";
5+
import { Command, commands } from "../components/utils/cmd/loader";
66

77
const PROJECT_CANIS_ALIS: string = process.env.PROJECT_CANIS_ALIAS || "Canis";
88

9-
export const info = {
9+
export const info: Command = {
1010
command: "ai",
1111
description: "Interact with the AI agent.",
1212
usage: "ai <query>",
@@ -50,7 +50,11 @@ export default async function (msg: Message): Promise<void> {
5050

5151
for (const key in commands) {
5252
const cmd = commands[key];
53-
if (cmd.role === "user" && excludeCommands.includes(cmd.command)) {
53+
if (
54+
cmd.role === "user" &&
55+
!excludeCommands.includes(cmd.command) &&
56+
!(cmd.optOutAI ?? false)
57+
) {
5458
prompt += `\n${cmd.command} - ${cmd.description}\n${cmd.usage}\n`;
5559
}
5660
}

src/components/utils/cmd/loader.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,34 @@ const basePath = path.join(__dirname, "..", "..", "..", "commands");
1010
import * as Sentry from "@sentry/node";
1111

1212
export const commandDirs = [basePath, path.join(basePath, "private")];
13-
export const commands: Record<
14-
string,
15-
{
16-
command: string;
17-
description: string;
18-
usage: string;
19-
example: string;
20-
role: string;
21-
cooldown: number;
22-
exec: (msg: Message) => Promise<void>;
23-
}
24-
> = {};
13+
export interface Command {
14+
/** The actual command keyword the bot will listen for */
15+
command: string;
16+
17+
/** A brief description of what the command does */
18+
description: string;
19+
20+
/** How to use the command (syntax) */
21+
usage: string;
22+
23+
/** Example usage of the command */
24+
example: string;
25+
26+
/** Required role to use the command (e.g., 'admin', 'moderator') */
27+
role: string;
28+
29+
/** Cooldown in seconds before the command can be reused */
30+
cooldown: number;
31+
32+
/** Optional: set to true if you don't want AI to process this command */
33+
optOutAI?: boolean;
34+
}
35+
36+
interface InternalCommands extends Command {
37+
/** The function that will be executed when the command is called */
38+
exec: (msg: Message) => Promise<void>;
39+
}
40+
export const commands: Record<string, InternalCommands> = {};
2541

2642
async function ensureDependencies(
2743
dependencies: { name: string; version: string }[],

0 commit comments

Comments
 (0)