FIx bot only show 1 nodes

This commit is contained in:
Hirzi
2022-06-29 07:20:40 +07:00
committed by GitHub
parent 1d0c7c503e
commit 9b962d0edd
3 changed files with 6 additions and 5 deletions

View File

@@ -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()

View File

@@ -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'))

View File

@@ -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"
}
}