From cd2f54a4a4efe339d7e08cd25afab11e8fd4fb42 Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Tue, 20 Sep 2022 17:36:02 +0200 Subject: [PATCH] feat: uptime on stats command --- commands/misc/stats.ts | 5 ++++- stats.js | 6 ++++++ twitchSchemas/SrIzan10.js | 12 ------------ 3 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 twitchSchemas/SrIzan10.js diff --git a/commands/misc/stats.ts b/commands/misc/stats.ts index 3914a4b..97c897a 100644 --- a/commands/misc/stats.ts +++ b/commands/misc/stats.ts @@ -19,6 +19,7 @@ export default commandModule({ const ramtotal = await axios(`http://192.168.1.44:7271/ramtotal`) const ramfree = await axios(`http://192.168.1.44:7271/ramfree`) const dockertotal = await axios(`http://192.168.1.44:7271/dockertotal`) + const nodeuptime = await axios(`http://192.168.1.44:7271/uptime`) const uptime = prettySeconds(process.uptime()) const embed = new EmbedBuilder() .setAuthor({name: `${ctx.user.username}`, iconURL: `${ctx.user.displayAvatarURL()}`}) @@ -33,7 +34,9 @@ export default commandModule({ {name: '\u200B', value: '\u200B', inline: true}, {name: 'Contenedores de Docker', value: `${dockertotal.data}`, inline: true}, {name: '\u200B', value: '\u200B', inline: true}, - {name: 'Tiempo encendido', value: `${uptime}`}, + {name: 'Tiempo encendido', value: `${uptime}`, inline: true}, + {name: '\u200B', value: '\u200B', inline: true}, + {name: 'Uptime del servidor', value: `${prettySeconds(`${nodeuptime.data}`)}`} ) await ctx.interaction.editReply({embeds: [embed]}) }, diff --git a/stats.js b/stats.js index b0ee95f..d718111 100644 --- a/stats.js +++ b/stats.js @@ -3,6 +3,7 @@ const port = 8080 const express = require('express'); const app = express(); const si = require('systeminformation'); +const os = require('os'); function formatBytes(bytes, decimals = 2) { if (bytes === 0) return '0 Bytes'; @@ -48,5 +49,10 @@ app.get("/dockertotal", async function (req, res) { res.send(`${docker.containers}`) }) +app.get("/uptime", async function (req, res) { + const uptime = os.uptime() + res.send(`${uptime}`) +}) + // start the server listening for requests app.listen(port, () => {console.log("The webserver is listening on port " + port)}); \ No newline at end of file diff --git a/twitchSchemas/SrIzan10.js b/twitchSchemas/SrIzan10.js deleted file mode 100644 index ce39a54..0000000 --- a/twitchSchemas/SrIzan10.js +++ /dev/null @@ -1,12 +0,0 @@ -const mongoose = require("mongoose") - -const twitchModel = new mongoose.Schema({ - title: { - type: String, - required: true - } -}) - -const twitch = mongoose.model("SrIzan10-twitch-schema", twitchModel) - -module.exports = twitch; \ No newline at end of file