adding embed to generation processor

This commit is contained in:
Raven Scott 2023-04-28 16:44:07 +02:00
parent 735b94360a
commit 38fba90d30

View File

@ -197,28 +197,45 @@ async function generateResponse(conversation, message) {
let time = 0
// define a function that shows the system load percentage and updates the message
const showSystemLoad = async () => {
time = time + 7
time = time + 7;
cpuStat.usagePercent(function(err, percent, seconds) {
if (err) {
return console.log(err);
}
const systemLoad = percent //the percentage cpu usage over all cores
const systemLoad = percent;
const freeMemory = os.freemem() / 1024 / 1024 / 1024;
const totalMemory = os.totalmem() / 1024 / 1024 / 1024;
const usedMemory = totalMemory - freeMemory;
const messageData = `Please wait, I am thinking...\nSystem Load: ${systemLoad.toFixed(2)}%\nMemory Usage: ${usedMemory.toFixed(2)} GB / ${totalMemory.toFixed(2)} GB | Time: ~${time} seconds.`;
const embedData = {
color: 0x0099ff,
title: 'Thinking...',
fields: [
{
name: 'System Load',
value: `${systemLoad.toFixed(2)}%`,
},
{
name: 'Memory Usage',
value: `${usedMemory.toFixed(2)} GB / ${totalMemory.toFixed(2)} GB`,
},
{
name: 'Time',
value: `~${time} seconds.`,
},
],
};
// if the message object doesn't exist, create it
if (!botMessage) {
(async () => {
botMessage = await message.channel.send(messageData);
})()
botMessage = await message.channel.send({ embeds: [embedData] });
})();
} else {
botMessage.edit(messageData); // otherwise, update the message
botMessage.edit({ embeds: [embedData] }); // otherwise, update the message
}
})
});
};
// call the function initially