Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/ai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AiPlugin } from './plugin';
import { AiPluginOptions } from './types';
import { getAiWorkerContext } from './ai-context-worker';
import { getCommandKit } from 'commandkit';
import type { Message } from 'discord.js';

/**
* Retrieves the AI context.
Expand All @@ -28,6 +29,21 @@ export function useAI() {
return aiPlugin;
}

/**
* Executes an AI command.
* @param message The message to execute the AI command on
* @example
* ```ts
* const message = await getMessageSomehow();
* // use AI to process the message
* await executeAI(message);
* ```
*/
export function executeAI(message: Message): Promise<void> {
const aiPlugin = useAI();
return aiPlugin.executeAI(message);
}

/**
* Defines the AI plugin for the application.
* @param options The options for the AI plugin
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AiPlugin extends RuntimePlugin<AiPluginOptions> {
commandkit: CommandKit,
message: Message,
): Promise<void> {
if (message.author.bot || !Object.keys(this.toolsRecord).length) return;
if (message.author.bot) return;
const {
messageFilter,
selectAiModel,
Expand Down