Compare commits
No commits in common. "f87b61fb2b70af9340aa6cc36a5ef822508c4e42" and "0caf82d7f6cae926823c0e85f87836382c17af0f" have entirely different histories.
f87b61fb2b
...
0caf82d7f6
55
llamabot.js
55
llamabot.js
@ -197,46 +197,29 @@ async function generateResponse(conversation, message) {
|
|||||||
let time = 0
|
let time = 0
|
||||||
// define a function that shows the system load percentage and updates the message
|
// define a function that shows the system load percentage and updates the message
|
||||||
const showSystemLoad = async () => {
|
const showSystemLoad = async () => {
|
||||||
time = time + 7;
|
time = time + 7
|
||||||
cpuStat.usagePercent(function(err, percent, seconds) {
|
cpuStat.usagePercent(function(err, percent, seconds) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const systemLoad = percent;
|
const systemLoad = percent //the percentage cpu usage over all cores
|
||||||
const freeMemory = os.freemem() / 1024 / 1024 / 1024;
|
const freeMemory = os.freemem() / 1024 / 1024 / 1024;
|
||||||
const totalMemory = os.totalmem() / 1024 / 1024 / 1024;
|
const totalMemory = os.totalmem() / 1024 / 1024 / 1024;
|
||||||
const usedMemory = totalMemory - freeMemory;
|
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 = {
|
// if the message object doesn't exist, create it
|
||||||
color: 0x0099ff,
|
if (!botMessage) {
|
||||||
title: 'Please wait.. I am Thinking...',
|
(async () => {
|
||||||
fields: [
|
botMessage = await message.channel.send(messageData);
|
||||||
{
|
})()
|
||||||
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
|
} else {
|
||||||
if (!botMessage) {
|
botMessage.edit(messageData); // otherwise, update the message
|
||||||
(async () => {
|
}
|
||||||
botMessage = await message.channel.send({ embeds: [embedData] });
|
})
|
||||||
})();
|
};
|
||||||
} else {
|
|
||||||
botMessage.edit({ embeds: [embedData] }); // otherwise, update the message
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// call the function initially
|
// call the function initially
|
||||||
await showSystemLoad();
|
await showSystemLoad();
|
||||||
|
Loading…
Reference in New Issue
Block a user