Fixed issue with bot status and embed field, also now you can disable panel stats users and servers

This commit is contained in:
Hirzi
2022-05-30 08:27:29 +07:00
committed by GitHub
parent af65a59359
commit 4894211fcd
3 changed files with 19 additions and 9 deletions

View File

@@ -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"
unit: 'gb' # You can use "gb", "mb", or "percent"
# Panel Users and Servers
panel_resource:
enable: true
servers: true
users: true

View File

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

View File

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