From 56dcc67ea28915a7755ead3e32b48c0f16c3e547 Mon Sep 17 00:00:00 2001 From: ShadowVR Date: Sat, 1 Jun 2024 17:02:50 -0400 Subject: [PATCH] Update --- events/messageCreate.js | 53 +++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/events/messageCreate.js b/events/messageCreate.js index b3b5e27..5dfda92 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -333,6 +333,23 @@ function restartBot() { process.exit(0); // Exits the current process, assuming your process manager restarts the bot } +const fs = require('fs'); +const { exec } = require('child_process'); + +// Function to restart the bot +function restartBot() { + console.log("Restarting bot..."); + process.exit(0); // Exits the current process, assuming your process manager restarts the bot +} + +// Function to save conversation for self-learning +function saveConversation(conversation) { + // Implement the logic to save the conversation + // For example, you can write it to a file or a database + const data = JSON.stringify(conversation, null, 2); + fs.appendFileSync('conversations.json', data + ',\n'); +} + // Before sending the response, check for mentions if (!fullAnswer.includes('@everyone') && !fullAnswer.includes('@here') && !fullAnswer.includes('@')) { if (fullAnswer.length <= 2000) { @@ -361,29 +378,29 @@ if (!fullAnswer.includes('@everyone') && !fullAnswer.includes('@here') && !fullA } } +// Save the conversation for self-learning +const conversation = { + user: message.author.id, + userMessage: question, + botResponse: fullAnswer +}; +saveConversation(conversation); - // Save the conversation for self-learning - const conversation = { - user: message.author.id, - userMessage: question, - botResponse: fullAnswer - }; - saveConversation(conversation); +conversations.set(message.author.id, messages.concat([{ "role": "assistant", "content": fullAnswer }])); - conversations.set(message.author.id, messages.concat([{ "role": "assistant", "content": fullAnswer }])); - } - } catch (error) { - console.error(chalk.bold.redBright(error)); +} catch (error) { + console.error(chalk.bold.redBright(error)); - if (error.response) { - await message.reply(error.response.error.message.substring(0, 2000)); - } else if (error.message) { - await message.reply(error.message.substring(0, 2000)); - } - } - } + if (error.response) { + await message.reply(error.response.error.message.substring(0, 2000)); + } else if (error.message) { + await message.reply(error.message.substring(0, 2000)); } } +} +} +} + // Command Handler if (message.content.toLowerCase().startsWith(config.Prefix)) {