From 9b962d0edde0760753e9ab11798e26675f4d0165 Mon Sep 17 00:00:00 2001 From: Hirzi <64255651+HirziDevs@users.noreply.github.com> Date: Wed, 29 Jun 2022 07:20:40 +0700 Subject: [PATCH] FIx bot only show 1 nodes --- handlers/checkStatus.js | 4 ++-- handlers/postStatus.js | 1 + package.json | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/handlers/checkStatus.js b/handlers/checkStatus.js index 06f5b08..03b15c0 100644 --- a/handlers/checkStatus.js +++ b/handlers/checkStatus.js @@ -80,7 +80,7 @@ module.exports = function checkStatus(client) { Authorization: 'Bearer ' + client.config.panel.key } }).then((res) => { - res.data.data.forEach((node) => { + res.data.data.forEach((node, i) => { axios(client.config.panel.url + '/api/application/nodes/' + node.attributes.id + '/configuration', { method: 'GET', headers: { @@ -120,7 +120,7 @@ module.exports = function checkStatus(client) { }) stats.then(() => { nodes.push(body) - resolve() + if (i + 1 === res.data.data.length) resolve() }) }).catch((err) => { resolve() diff --git a/handlers/postStatus.js b/handlers/postStatus.js index 8483e95..f804519 100644 --- a/handlers/postStatus.js +++ b/handlers/postStatus.js @@ -6,6 +6,7 @@ module.exports = async function postStatus(client, panel, nodes) { if (!client.config.nodes_resource) client.config.nodes_resource = client.config.resource if (!client.config.nodes_resource.blacklist) client.config.nodes_resource.blacklist = [] if (!Array.isArray(client.config.nodes_resource.blacklist) && Number.isInteger(client.config.nodes_resource.blacklist)) client.config.nodes_resource.blacklist = [client.config.nodes_resource.blacklist] + if (!['mb', 'gb', 'percent'].includes(client.config.nodes_resource.unit)) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Unit at nodes_resource')) if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! This bot is not on any discord servers')) diff --git a/package.json b/package.json index 59559dd..5f0b5ac 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,12 @@ "start": "node index.js" }, "dependencies": { - "axios": "^0.26.1", + "axios": "^0.27.2", "chalk": "4.1.1", - "discord.js": "^13.8.0", + "discord.js": "^13.8.1", "js-yaml": "^4.1.0" }, "engines": { - "node": "16.x" + "node": "^16.x" } } \ No newline at end of file