From 23d3b315d126e862592abe06fc6818d49100e3e1 Mon Sep 17 00:00:00 2001 From: theimperious1 Date: Sun, 10 Nov 2024 00:56:34 -0500 Subject: [PATCH] Name changes, remove redundant func param --- src/discord/commands/global/d.ai.ts | 4 ++-- src/global/commands/g.ai.ts | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/discord/commands/global/d.ai.ts b/src/discord/commands/global/d.ai.ts index bd8ebac8c..8cf5066ba 100644 --- a/src/discord/commands/global/d.ai.ts +++ b/src/discord/commands/global/d.ai.ts @@ -48,7 +48,7 @@ import { import { SlashCommand } from '../../@types/commandDef'; import { embedTemplate } from '../../utils/embedTemplate'; import commandContext from '../../utils/context'; -import aiChat, { aiModerate, handleMessage } from '../../../global/commands/g.ai'; +import aiChat, { aiModerate, handleAiMessageQueue } from '../../../global/commands/g.ai'; /* TODO * only direct @ message should trigger a response @@ -2175,7 +2175,7 @@ export async function aiMessage( }, 30000); // Failsafe to stop typing indicator after 30 seconds try { - const chatResponse = await handleMessage(messageData.author.id, aiPersona, messageList, messageData, attachmentInfo); + const chatResponse = await handleAiMessageQueue(aiPersona, messageList, messageData, attachmentInfo); response = chatResponse.response; promptTokens = chatResponse.promptTokens; completionTokens = chatResponse.completionTokens; diff --git a/src/global/commands/g.ai.ts b/src/global/commands/g.ai.ts index 14854db34..3b7c7da0f 100644 --- a/src/global/commands/g.ai.ts +++ b/src/global/commands/g.ai.ts @@ -123,8 +123,7 @@ const aiFunctions = [ ]; // Main function for aiChat to handle incoming messages and return a Promise with response data -export function handleMessage( - userId: string, +export function handleAiMessageQueue( aiPersona: ai_personas, messages: { role: 'user'; content: string }[], messageData: Message, @@ -134,11 +133,11 @@ export function handleMessage( promptTokens: number; completionTokens: number; }> { - if (!userQueues.has(userId)) { - userQueues.set(userId, { queue: [], isProcessing: false }); + if (!userQueues.has(messageData.author.id)) { + userQueues.set(messageData.author.id, { queue: [], isProcessing: false }); } - const userQueue = userQueues.get(userId)!; + const userQueue = userQueues.get(messageData.author.id)!; // Push the new message data into the user's queue return new Promise((resolve) => { @@ -152,7 +151,7 @@ export function handleMessage( // If the user is not currently processing, start processing if (!userQueue.isProcessing) { - processNextMessage(userId); + processNextMessage(messageData.author.id); } }); }