From 4894211fcd1cb0f8df4763e1e70679b29fecb6b7 Mon Sep 17 00:00:00 2001 From: Hirzi <64255651+HirziDevs@users.noreply.github.com> Date: Mon, 30 May 2022 08:27:29 +0700 Subject: [PATCH] Fixed issue with bot status and embed field, also now you can disable panel stats users and servers --- config.yml | 10 ++++++++-- events/ready.js | 2 +- handlers/postStatus.js | 16 ++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/config.yml b/config.yml index 98a358b..e543a4a 100644 --- a/config.yml +++ b/config.yml @@ -53,7 +53,7 @@ button: # Status Message Configuration status: - online: ':green_circle: Online' # TODO how to use custom emoji + online: ':green_circle: Online' offline: ':red_circle: Offline' # Node Resource @@ -62,4 +62,10 @@ resource: servers: true location: true allocations: true - unit: 'gb' # You can use "gb", "mb", or "percent" \ No newline at end of file + unit: 'gb' # You can use "gb", "mb", or "percent" + +# Panel Users and Servers +panel_resource: + enable: true + servers: true + users: true \ No newline at end of file diff --git a/events/ready.js b/events/ready.js index 0f3aa4b..ea01800 100644 --- a/events/ready.js +++ b/events/ready.js @@ -11,7 +11,7 @@ module.exports = { if (client.guilds.cache.size === 0) return console.log(chalk.cyan('[PteroStats]') + chalk.red(' There is bot is not in servers, please invite the bot first!')) if (client.config.bot_status.enable) { - if (!['PLAYING', 'WATCHING', 'LISTENING', 'COMPETING'].includes(client.config.status.type)) { + if (!['PLAYING', 'WATCHING', 'LISTENING', 'COMPETING'].includes(client.config.bot_status.type)) { console.log('Invalid Status Type!, Can be "WATCHING", "PLAYING", "LISTENING", or "COMPETING"') } else { client.user.setActivity(client.config.status.text, { type: client.config.status.type }) diff --git a/handlers/postStatus.js b/handlers/postStatus.js index 6c0026d..7aeb268 100644 --- a/handlers/postStatus.js +++ b/handlers/postStatus.js @@ -73,7 +73,7 @@ module.exports = async function postStatus(client, panel, nodes) { text = 'There is no nodes to display' resolve() } else { - text = messages.embeds[0].fields[0].value.replaceAll(client.config.status.online, client.config.status.offline) + text = messages.embeds[0].description.replaceAll(client.config.status.online, client.config.status.offline) if (!panel.status && String(String(messages.embeds[0].fields[1].value).split('\n')[2]).split('')[String(String(messages.embeds[0].fields[1].value).split('\n')[2]).length - 1] !== '`') { panel.total_users = String(String(messages.embeds[0].fields[1].value).split('\n')[2]).split('')[String(String(messages.embeds[0].fields[1].value).split('\n')[2]).length - 1] panel.total_servers = String(String(messages.embeds[0].fields[1].value).split('\n')[3]).split('')[String(String(messages.embeds[0].fields[1].value).split('\n')[3]).length - 1] @@ -86,11 +86,15 @@ module.exports = async function postStatus(client, panel, nodes) { stats.then(async () => { embed.setDescription(desc + '\n**Nodes Stats [' + nodes.length + ']**' + text) - embed.addField('Panel Stats', - '**Status:** ' + String(panel.status).replace('true', client.config.status.online).replace('false', client.config.status.offline) + '\n\n' + - 'Users: ' + String(panel.total_users).replace('-1', '`Unknown`') + '\n' + - 'Servers: ' + String(panel.total_servers).replace('-1', '`Unknown`') - ) + + if (client.config.panel_resource.enable) { + let stats = '**Status:** ' + String(panel.status).replace('true', client.config.status.online).replace('false', client.config.status.offline) + '\n\n' + + if (client.config.panel_resource.users) stats = stats + 'Users: ' + String(panel.total_users).replace('-1', '`Unknown`') + '\n' + if (client.config.panel_resource.servers) stats = stats + 'Servers: ' + String(panel.total_servers).replace('-1', '`Unknown`') + + embed.addField('Panel Stats', stats) + } if (client.config.embed.field.enable) { embed.addField(client.config.embed.field.title, client.config.embed.field.description.replaceAll('{{time}}', format))