From 5d2bc4ea44f3842fa5034fe15e0999215b60fa58 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Wed, 31 Mar 2021 20:24:32 -0600 Subject: [PATCH] mem stats bugs and n?mem --- commands/misc/info.js | 3 +-- commands/misc/mem.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 commands/misc/mem.js diff --git a/commands/misc/info.js b/commands/misc/info.js index 57460c5..6f7bb73 100644 --- a/commands/misc/info.js +++ b/commands/misc/info.js @@ -16,7 +16,6 @@ module.exports = { }, async execute(message, msg, args, cmd, prefix, mention, client) { let botData = await require('../../models/bot').findOne({finder: 'lel'}); - let user = await UserData.findOne({uid: message.author.id}); return message.channel.send(new Discord.MessageEmbed() @@ -27,7 +26,7 @@ module.exports = { .addField("Restarts", botData.restarts, true) .addField("Commands Executed", `${botData.commands}${user ? `\nYou: **${user.commands}**|**${Math.floor((user.commands / botData.commands) * 100)}%**` : ''}`, true) .addField("Last Restart", moment(botData.lastRestart).fromNow(), true) - .addField("Mem", `\`${process.memoryUsage().heapUsed / 1024 / 1024}MB\` heap of \`${process.memoryUsage().heapTotal / 1024 / 1024}MB\` allocated. | **${Math.floor((process.memoryUsage().heapTotal / process.memoryUsage().heapUsed) * 100)}%**\nTotal RAM: \`${os.totalmem() / 1024 / 1024 / 1024}GB\` | Free RAM: \`${os.freemem() / 1024 / 1024 / 1024}GB\``, true) + .addField("Mem", `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB\` heap of \`${(process.memoryUsage().heapTotal / 1024 / 1024).toFixed(2)}MB\` allocated. | **${Math.floor((process.memoryUsage().heapUsed / process.memoryUsage().heapTotal) * 100)}%**\nTotal RAM: \`${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)}GB\` | Free RAM: \`${(os.freemem() / 1024 / 1024 / 1024).toFixed(2)}GB\``, true) .setColor("c375f0") .setFooter("Natsuki") .setTimestamp()); diff --git a/commands/misc/mem.js b/commands/misc/mem.js new file mode 100644 index 0000000..35eaac6 --- /dev/null +++ b/commands/misc/mem.js @@ -0,0 +1,20 @@ +const Discord = require('discord.js'); + +module.exports = { + name: "mem", + aliases: ['memory', 'ram', 'memstats'], + meta: { + category: 'Misc', + description: "Shows memory usage stats", + syntax: '`mem`', + extra: null + }, + help: "shows my memory usage stats", + async execute(message, msg, args, cmd, prefix, mention, client) { + return message.channel.send(new Discord.MessageEmbed() + .setTitle("RAM Usage") + .setDescription("Mem", `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB\` heap of \`${(process.memoryUsage().heapTotal / 1024 / 1024).toFixed(2)}MB\` allocated. | **${Math.floor((process.memoryUsage().heapUsed / process.memoryUsage().heapTotal) * 100)}%**\nTotal RAM: \`${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)}GB\` | Free RAM: \`${(os.freemem() / 1024 / 1024 / 1024).toFixed(2)}GB\``) + .setColor('c375f0') + ); + } +}; \ No newline at end of file