code cleanup

This commit is contained in:
Raven Scott 2023-03-25 19:50:48 +02:00
parent 24cf2323a3
commit a8c1138ad7
5 changed files with 11 additions and 22 deletions

View File

@ -1,13 +1,9 @@
const { EmbedBuilder } = require('discord.js'); const { EmbedBuilder } = require('discord.js');
let cpu = require('cpu-load') m
odule.exports = {
module.exports = {
name: "about", name: "about",
description: "Info about the bot", description: "Info about the bot",
run: async (client, interaction) => { run: async (client, interaction) => {
cpu(1000, function (load) {
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor("#FF0000") .setColor("#FF0000")
.setTitle("About rAI") .setTitle("About rAI")
@ -15,7 +11,5 @@ module.exports = {
.setTimestamp() .setTimestamp()
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
interaction.followUp({ embeds: [embed] }); interaction.followUp({ embeds: [embed] });
})
}, },
}; };

View File

@ -13,16 +13,15 @@ module.exports = {
"required": true, "required": true,
"type": 3 // 6 is type USER "type": 3 // 6 is type USER
}], }],
run: async (client, interaction) => { run: async (client, interaction) => {
const file = './cache/' + interaction.user.id; const file = './cache/' + interaction.user.id;
let chatToSend = interaction.options._hoistedOptions[0].value; let chatToSend = interaction.options._hoistedOptions[0].value;
// Check if another request is already being processed // Check if another request is already being processed
if (isProcessing) { if (isProcessing) {
interaction.editReply('Sorry, another request is already being processed. Please try again in a few minutes.'); interaction.editReply('Sorry, another request is already being processed. Please try again in a few minutes.');
return; return;
} }
// Set the semaphore to true // Set the semaphore to true
isProcessing = true; isProcessing = true;

View File

@ -18,7 +18,6 @@ module.exports = {
sendImmediately: true sendImmediately: true
}) })
.then((response) => { .then((response) => {
// console.log(response)
const obj = { id: response.body } const obj = { id: response.body }
jsonfile.writeFile(file, obj, function (err) { jsonfile.writeFile(file, obj, function (err) {

View File

@ -11,8 +11,6 @@ module.exports = {
jsonfile.readFile(file, function (err, obj) { jsonfile.readFile(file, function (err, obj) {
if (err) return interaction.editReply('Please create a session using /create-session.'); if (err) return interaction.editReply('Please create a session using /create-session.');
console.dir(obj)
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor("#FF0000") .setColor("#FF0000")

View File

@ -2,7 +2,6 @@ const axios = require('axios');
const jsonfile = require('jsonfile'); const jsonfile = require('jsonfile');
let session2; let session2;
function parseQuestionsAndAnswers(jsonStr) { function parseQuestionsAndAnswers(jsonStr) {
const obj = JSON.parse(jsonStr); const obj = JSON.parse(jsonStr);
const questions = obj.questions; const questions = obj.questions;
@ -16,8 +15,8 @@ module.exports = {
run: async (client, interaction) => { run: async (client, interaction) => {
const file = './cache/' + interaction.user.id; const file = './cache/' + interaction.user.id;
await jsonfile.readFile(file, async function (err, session) { await jsonfile.readFile(file, async function (err, session) {
if (err) return interaction.editReply('Please create a session using /create-session.'); if (err) return interaction.editReply('Please create a session using /create-session.');
session2 = session.id; session2 = session.id;