mirror of
https://github.com/HirziDevs/PteroStats
synced 2026-01-08 07:11:48 +00:00
Add TB Unit and other thing
This commit is contained in:
@@ -21,7 +21,7 @@ panel:
|
||||
# set to false if you want to disable option
|
||||
message:
|
||||
content: false
|
||||
image: false # If you enable image on message it upload the image first before sending or editing message and it will delay stats
|
||||
attachment: false # If you enable attachment on message it upload the attachment first before sending or editing message and it will delay the stats
|
||||
|
||||
embed:
|
||||
title: 'PteroStats'
|
||||
@@ -67,7 +67,7 @@ nodes_resource:
|
||||
servers: true
|
||||
location: true
|
||||
allocations: true
|
||||
unit: 'gb' # You can use "gb", "mb", or "percent"
|
||||
unit: 'gb' # You can use "gb", "mb", "tb", or "percent"
|
||||
|
||||
# Panel Users and Servers
|
||||
panel_resource:
|
||||
|
||||
@@ -10,8 +10,8 @@ module.exports = {
|
||||
|
||||
if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! This bot is not on any discord servers'))
|
||||
|
||||
if (client.config.bot_status.enable) {
|
||||
if (!['PLAYING', 'WATCHING', 'LISTENING', 'COMPETING'].includes(client.config.bot_status.type.toUpperCase())) {
|
||||
if (client.config.bot_status.enable && client.config.bot_status.text.length > 0) {
|
||||
if (!['PLAYING', 'WATCHING', 'LISTENING', 'COMPETING'].includes(client.config.bot_status.type.toUpperCase() || client.config.bot_status.type.length < 1 )) {
|
||||
console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Status Type!, Can be "WATCHING", "PLAYING", "LISTENING", or "COMPETING"'))
|
||||
} else {
|
||||
client.user.setActivity(client.config.bot_status.text, { type: client.config.bot_status.type.toUpperCase() })
|
||||
|
||||
@@ -104,7 +104,6 @@ module.exports = function checkStatus(client) {
|
||||
}
|
||||
|
||||
const stats = new Promise((statsResolve, statsReject) => {
|
||||
let done = false
|
||||
axios(node.attributes.scheme + '://' + node.attributes.fqdn + ':' + node.attributes.daemon_listen + '/api/servers', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -113,16 +112,14 @@ module.exports = function checkStatus(client) {
|
||||
Authorization: 'Bearer ' + data.data.token
|
||||
}
|
||||
}).then((status) => {
|
||||
done = true
|
||||
statsResolve()
|
||||
return statsResolve()
|
||||
}).catch((err) => {
|
||||
body.status = false
|
||||
done = true
|
||||
statsResolve()
|
||||
return statsResolve()
|
||||
})
|
||||
setTimeout(() => {
|
||||
if (!done) body.status = false
|
||||
statsResolve()
|
||||
body.status = false
|
||||
return statsResolve()
|
||||
}, 1000)
|
||||
})
|
||||
stats.then(() => {
|
||||
|
||||
@@ -6,7 +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.toLowerCase())) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! Invalid Unit at nodes config'))
|
||||
if (!client.config.message.attachment) client.config.message.attachment = client.config.message.image
|
||||
|
||||
if (client.guilds.cache.size < 1) return console.log(chalk.cyan('[PteroStats] ') + chalk.red('Err! This bot is not on any discord servers'))
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = async function postStatus(client, panel, nodes) {
|
||||
const files = []
|
||||
|
||||
if (client.config.message.content) content = client.config.message.content
|
||||
if (client.config.message.image) files.push(new MessageAttachment(client.config.message.image))
|
||||
if (client.config.message.attachment) files.push(new MessageAttachment(client.config.message.attachment))
|
||||
|
||||
if (client.config.embed.title) embed.setTitle(client.config.embed.title)
|
||||
if (client.config.embed.description) desc = client.config.embed.description + '\n'
|
||||
@@ -50,6 +50,11 @@ module.exports = async function postStatus(client, panel, nodes) {
|
||||
const title = data.name + ': ' + String(data.status).replace('true', client.config.status.online).replace('false', client.config.status.offline)
|
||||
let description = '```'
|
||||
switch (client.config.nodes_resource.unit.toLowerCase()) {
|
||||
case 'tb':
|
||||
description = description +
|
||||
'\nMemory : ' + Math.floor(data.memory_min / 1000000).toLocaleString() + ' TB / ' + Math.floor(data.memory_max / 1000000).toLocaleString() + ' TB' +
|
||||
'\nDisk : ' + Math.floor(data.disk_min / 1000000).toLocaleString() + ' TB / ' + Math.floor(data.disk_max / 1000000).toLocaleString() + ' TB'
|
||||
break;
|
||||
case 'gb':
|
||||
description = description +
|
||||
'\nMemory : ' + Math.floor(data.memory_min / 1000).toLocaleString() + ' GB / ' + Math.floor(data.memory_max / 1000).toLocaleString() + ' GB' +
|
||||
|
||||
Reference in New Issue
Block a user