Skip to content

Commit ee29d99

Browse files
committed
feat: add executeAI function to process Discord messages and refine message handling in AiPlugin
1 parent 9889ead commit ee29d99

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/ai/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AiPlugin } from './plugin';
33
import { AiPluginOptions } from './types';
44
import { getAiWorkerContext } from './ai-context-worker';
55
import { getCommandKit } from 'commandkit';
6+
import type { Message } from 'discord.js';
67

78
/**
89
* Retrieves the AI context.
@@ -28,6 +29,21 @@ export function useAI() {
2829
return aiPlugin;
2930
}
3031

32+
/**
33+
* Executes an AI command.
34+
* @param message The message to execute the AI command on
35+
* @example
36+
* ```ts
37+
* const message = await getMessageSomehow();
38+
* // use AI to process the message
39+
* await executeAI(message);
40+
* ```
41+
*/
42+
export function executeAI(message: Message): Promise<void> {
43+
const aiPlugin = useAI();
44+
return aiPlugin.executeAI(message);
45+
}
46+
3147
/**
3248
* Defines the AI plugin for the application.
3349
* @param options The options for the AI plugin

packages/ai/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class AiPlugin extends RuntimePlugin<AiPluginOptions> {
6868
commandkit: CommandKit,
6969
message: Message,
7070
): Promise<void> {
71-
if (message.author.bot || !Object.keys(this.toolsRecord).length) return;
71+
if (message.author.bot) return;
7272
const {
7373
messageFilter,
7474
selectAiModel,

0 commit comments

Comments
 (0)