From a8c1138ad7000f014d08dc2e7819baad0e77a817 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sat, 25 Mar 2023 19:50:48 +0200 Subject: [PATCH] code cleanup --- commands/Info/about.js | 24 +++++++++--------------- commands/Info/chat.js | 3 +-- commands/Info/new-chat.js | 1 - commands/Info/session-id.js | 2 -- commands/Info/view-session-history.js | 3 +-- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/commands/Info/about.js b/commands/Info/about.js index 7de69ef..f69d4ca 100644 --- a/commands/Info/about.js +++ b/commands/Info/about.js @@ -1,21 +1,15 @@ const { EmbedBuilder } = require('discord.js'); -let cpu = require('cpu-load') - -module.exports = { +m +odule.exports = { name: "about", description: "Info about the bot", - run: async (client, interaction) => { - cpu(1000, function (load) { - - const embed = new EmbedBuilder() - .setColor("#FF0000") - .setTitle("About rAI") - .setDescription(`Latency : ${client.ws.ping}ms\n\nrAI is a bot managed by \`snxraven#8205\` running an LLM called Alpaca.\n\nSpecs: Intel i7-1065G7 (8) @ 3.900GHz with 11 GB of RAM\nChat is set to 7 Threads\nConfigured Memory Speed: 3733 MT/s\nUSB Liveboot\n\nSingle Task Only - 256 Max Token Output`) - .setTimestamp() - .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); - interaction.followUp({ embeds: [embed] }); - }) - + const embed = new EmbedBuilder() + .setColor("#FF0000") + .setTitle("About rAI") + .setDescription(`Latency : ${client.ws.ping}ms\n\nrAI is a bot managed by \`snxraven#8205\` running an LLM called Alpaca.\n\nSpecs: Intel i7-1065G7 (8) @ 3.900GHz with 11 GB of RAM\nChat is set to 7 Threads\nConfigured Memory Speed: 3733 MT/s\nUSB Liveboot\n\nSingle Task Only - 256 Max Token Output`) + .setTimestamp() + .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); + interaction.followUp({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/Info/chat.js b/commands/Info/chat.js index 537df99..989a2c2 100644 --- a/commands/Info/chat.js +++ b/commands/Info/chat.js @@ -13,16 +13,15 @@ module.exports = { "required": true, "type": 3 // 6 is type USER }], + run: async (client, interaction) => { const file = './cache/' + interaction.user.id; let chatToSend = interaction.options._hoistedOptions[0].value; - // Check if another request is already being processed if (isProcessing) { interaction.editReply('Sorry, another request is already being processed. Please try again in a few minutes.'); return; } - // Set the semaphore to true isProcessing = true; diff --git a/commands/Info/new-chat.js b/commands/Info/new-chat.js index 527e39e..e85cd1b 100644 --- a/commands/Info/new-chat.js +++ b/commands/Info/new-chat.js @@ -18,7 +18,6 @@ module.exports = { sendImmediately: true }) .then((response) => { - // console.log(response) const obj = { id: response.body } jsonfile.writeFile(file, obj, function (err) { diff --git a/commands/Info/session-id.js b/commands/Info/session-id.js index 24f7e4d..00c0d48 100644 --- a/commands/Info/session-id.js +++ b/commands/Info/session-id.js @@ -11,8 +11,6 @@ module.exports = { jsonfile.readFile(file, function (err, obj) { if (err) return interaction.editReply('Please create a session using /create-session.'); - console.dir(obj) - const embed = new EmbedBuilder() .setColor("#FF0000") diff --git a/commands/Info/view-session-history.js b/commands/Info/view-session-history.js index d165952..669f9d4 100644 --- a/commands/Info/view-session-history.js +++ b/commands/Info/view-session-history.js @@ -2,7 +2,6 @@ const axios = require('axios'); const jsonfile = require('jsonfile'); let session2; - function parseQuestionsAndAnswers(jsonStr) { const obj = JSON.parse(jsonStr); const questions = obj.questions; @@ -16,8 +15,8 @@ module.exports = { run: async (client, interaction) => { const file = './cache/' + interaction.user.id; - await jsonfile.readFile(file, async function (err, session) { + if (err) return interaction.editReply('Please create a session using /create-session.'); session2 = session.id;