From b8e0a40f7324d66d777b1d3eb90695cf58e493d1 Mon Sep 17 00:00:00 2001 From: ShadowVirtual Date: Tue, 30 Apr 2024 18:52:51 -0800 Subject: [PATCH] Update handleDirectMessage function to include knowledge base in messageCreate.js --- events/messageCreate.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/events/messageCreate.js b/events/messageCreate.js index 07dbf8b..95925d5 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -3,6 +3,7 @@ const openAI = require('openai'); const chalk = require('chalk'); const ms = require('ms'); const fs = require('node:fs'); +const path = require('node:path'); const func = require('../utils/functions'); const settings = require('../utils/settings'); const config = require('../configs/config.json'); @@ -349,12 +350,14 @@ if (message.content.toLowerCase().startsWith(config.Prefix)) { // Function to handle direct messages async function handleDirectMessage(message) { + const knowledge = fs.readFileSync(path.join(__dirname, 'completion.txt'), 'utf-8'); + if (conversations.has(message.author.id)) { const oldMessages = conversations.get(message.author.id); let messages = [{ "role": "system", - "content": completionPrompt + "content": `You are a unique user in a Discord server. Engage in conversations naturally, considering the context and your surroundings. Share your thoughts, opinions, and experiences as if you were a real person. Use emojis, slang, and a casual tone to blend in with other users. Avoid sounding robotic or generic, and aim to create a distinct personality that others can relate to and enjoy interacting with. Your knowledge base: ${knowledge}` }]; messages = messages.concat(oldMessages);