From 46c94908dfcbb608d672b867e5517a2288adf927 Mon Sep 17 00:00:00 2001 From: Hirzi <64255651+HirziDevs@users.noreply.github.com> Date: Mon, 2 Jan 2023 13:15:40 +0000 Subject: [PATCH] refactor!: change `enable` at nodes_settings to `details` and add `status` at panel_settings to enable or disable panel status field --- config.yml | 3 ++- events/ready.js | 7 ------- handlers/postStatus.js | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/config.yml b/config.yml index 434817c..671a8f4 100644 --- a/config.yml +++ b/config.yml @@ -65,7 +65,7 @@ status: # How to get nodes id: https://github.com/HirziDevs/PteroStats#blacklist-nodes nodes_settings: blacklist: [] # You can add node id to remove the node from status embed (Example: "blacklist: [1]") - enable: false + details: false # enable nodes details like memory and disk servers: true location: true allocations: true @@ -73,6 +73,7 @@ nodes_settings: # Panel Users and Servers Settings panel_settings: + status: true # enable panel stats under nodes stats servers: true users: true diff --git a/events/ready.js b/events/ready.js index e222be0..ab21a3a 100644 --- a/events/ready.js +++ b/events/ready.js @@ -22,13 +22,6 @@ module.exports = { client.config.refresh = 10 } - if (client.config.bot_status || client.config.nodes_resource || client.config.panel_resource) { - console.log(chalk.cyan('[PteroStats] ') + chalk.red('You used `bot_status`, `panel_resource` and `nodes_resource` instead of `presence`, `panel_settings` and `nodes_settings` in the config, please update your config file at ') + chalk.green('https://github.com/HirziDevs/PteroStats/blob/main/config.yml ') + chalk.red('before it can no longer be supported')) - client.config.presence = client.config.bot_status - client.config.nodes_settings = client.config.nodes_resource - client.config.panel_settings = client.config.panel_resource - } - if (client.config.presence.text && client.config.presence.type) { switch (client.config.presence.type.toLowerCase()) { case 'playing': diff --git a/handlers/postStatus.js b/handlers/postStatus.js index 2389473..c4977ab 100644 --- a/handlers/postStatus.js +++ b/handlers/postStatus.js @@ -68,7 +68,7 @@ module.exports = async function postStatus({ client, panel, nodes }) { description = description + '\n```' - if (client.config.nodes_settings.enable) { + if (client.config.nodes_settings.details) { text = text + '\n**' + title.replace(':', ':**') + '\n' + description } else { text = text + '\n**' + title.replace(':', ':**') @@ -102,7 +102,7 @@ module.exports = async function postStatus({ client, panel, nodes }) { embed.setDescription(desc.replaceAll('{{time}}', format) + '\n**Nodes Stats [' + Math.floor(nodes.length - blacklist) + ']**' + text) const EmbedFields = [] - if (client.config.panel_settings.users || client.config.panel_settings.servers) { + if (client.config.panel_settings.status) { let stats = '**Status:** ' + String(panel.status).replace('true', client.config.status.online).replace('false', client.config.status.offline) + '\n\n' if (client.config.panel_settings.users) stats = stats + 'Users: ' + String(panel.total_users).replace('-1', '`Unknown`') + '\n'