From 5b961b6ba815912b6ceab8d48fd4e647f5ebe39c Mon Sep 17 00:00:00 2001 From: Hirzi <64255651+HirziDevs@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:49:42 +0700 Subject: [PATCH] refactor(logging): change from using quotes to color for nodes, channel, and bot name --- handlers/getStats.js | 6 +++--- index.js | 25 ++++++++++++------------ package.json | 46 ++++++++++++++++++++++---------------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/handlers/getStats.js b/handlers/getStats.js index 47d6549..cf62382 100644 --- a/handlers/getStats.js +++ b/handlers/getStats.js @@ -14,13 +14,13 @@ module.exports = async function getStats() { if (!nodesStats) throw new Error("Failed to get nodes attributes"); const statusPromises = nodesStats.slice(0, config.nodes_settings.limit).map(async (node) => { - console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow(`Fetching "${node.attributes.name}" configuration...`)) + console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow(`Fetching ${cliColor.blueBright(node.attributes.name)} configuration...`)) const nodeConfig = await getNodeConfiguration(node.attributes.id); - console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow(`Checking "${node.attributes.name}" wings status...`)) + console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow(`Checking ${cliColor.blueBright(node.attributes.name)} wings status...`)) const nodeStatus = await promiseTimeout(getWingsStatus(node, nodeConfig.token), config.timeout * 1000); if (!nodeStatus) - console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright(`Node "${node.attributes.name}" is currently offline`)) + console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright(`Node ${cliColor.blueBright(node.attributes.name)} is currently offline.`)) return { attributes: { name: node.attributes.name, diff --git a/index.js b/index.js index 4b356a1..703646b 100644 --- a/index.js +++ b/index.js @@ -2,20 +2,21 @@ const { Client, GatewayIntentBits, EmbedBuilder, time, ActivityType, ActionRowBu const cachePath = require('node:path').join(__dirname, "./cache.json"); const fs = require("node:fs"); const cliColor = require("cli-color"); +const package = require("./package.json") console.log(` - _${cliColor.blueBright.bold("Pterodactyl & Pelican")}___ ______ ______ - /\\ ___\\ /\\__ _\\ /\\ __ \\ /\\__ _\\ /\\ ___\\ - \\ \\___ \\ \\/_ \\ \\/ \\ \\ \\_\\ \\ \\/_/\\ \\/ \\ \\___ \\ - \\/\\_____\\ \\ \\_\\ \\ \\_\\ \\_\\ \\ \\_\\ \\/\\_____\\ - \\/_____/ \\/_/ \\/_/\\/_/ \\/_/ \\/_____/${cliColor.yellowBright.bold("4.0.0-dev")}`); + _${cliColor.blueBright.bold(`${cliColor.underline("Ptero")}dact${cliColor.underline("yl & P")}eli${cliColor.underline("can")}`)}___ ______ ______ + /\\ ___\\ /\\__ _\\ /\\ __ \\ /\\__ _\\ /\\ ___\\ + \\ \\___ \\ \\/_ \\ \\/ \\ \\ \\_\\ \\ \\/_/\\ \\/ \\ \\___ \\ + \\/\\_____\\ \\ \\_\\ \\ \\_\\ \\_\\ \\ \\_\\ \\/\\_____\\ + \\/_____/ \\/_/ \\/_/\\/_/ \\/_/ \\/_____/${cliColor.yellowBright.bold(`${package.version}-dev`)}`); console.log( ` \nCopyright © 2022 - ${new Date().getFullYear()} HirziDevs & Contributors` + " \n \nDiscord: https://discord.znproject.my.id" + " \n Source: https://github.com/HirziDevs/PteroStats" + " \nLicense: https://github.com/Hirzidevs/PteroStats/blob/main/LICENSE" + - " \n \nPteroStats is a Discord Bot that designed to check Pterodactyl or Pelican Panel stats and post it to your Discord server. \n \n" + ` \n \n${package.description}\n ` ); if (!fs.existsSync(".env")) return require("./handlers/installer.js")() @@ -25,8 +26,8 @@ const config = require("./handlers/config.js"); const convertUnits = require("./handlers/convertUnits.js"); const getStats = require("./handlers/getStats.js"); -console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.greenBright("Starting bot...")); -console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright("You are using development build! some features may not work.")); +console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.green("Starting bot...")); +console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright("You are using a development build! Some features may not work as intended.")); const client = new Client({ intents: [GatewayIntentBits.Guilds] @@ -42,7 +43,7 @@ async function startGetStatus() { users: results.users, }); } catch { - console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright("Panel is offline")); + console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright("Panel is currently offline.")); fs.readFile(cachePath, (err, data) => { if (err) { @@ -68,7 +69,7 @@ async function startGetStatus() { } client.once("ready", () => { - console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.greenBright(`${client.user.tag} is online!`)); + console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.green(`${cliColor.blueBright(client.user.tag)} is online!`)); if (config.presence.enable) { if (config.presence.text && config.presence.type) { @@ -184,7 +185,7 @@ async function createMessage({ cache, panel, nodes, servers, users }) { const messages = await channel.messages.fetch({ limit: 10 }); const botMessage = messages.find(msg => msg.author.id === client.user.id); - console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.greenBright(`Panel stats successfuly posted to the "${channel.name}" channel!`)); + console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.green(`Panel stats successfully posted to the ${cliColor.blueBright(channel.name)} channel!`)); setTimeout(() => startGetStatus(), config.refresh * 1000); @@ -218,4 +219,4 @@ try { } catch { console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.redBright("Discord Error | Invalid Discord Bot Token! Make sure you have the correct token in the config!")); process.exit(); -} +} \ No newline at end of file diff --git a/package.json b/package.json index f974cf6..b6a12b5 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,25 @@ { - "name": "pterostats", - "version": "4.0.0", - "description": "PteroStats is a Discord Bot that designed to check Pterodactyl or Pelican Panel stats and post it to your Discord server.", - "license": "MIT", - "repository": "HirziDevs/PteroStats", - "homepage": "https://pterostats.znproject.my.id", - "bugs": { - "email": "hirzidevs@gmail.com", - "url": "https://github.com/HirziDevs/PteroStats/issues" - }, - "scripts": { - "start": "node index.js" - }, - "dependencies": { - "axios": "^1.7.7", - "cli-color": "^2.0.4", - "discord.js": "^14.16.1", - "dotenv": "^16.4.5", - "js-yaml": "^4.1.0" - }, - "engines": { - "node": ">=18" - } + "name": "pterostats", + "version": "4.0.0", + "description": "PteroStats is a Discord App that designed to check Pterodactyl or Pelican Panel stats and post it to your Discord server.", + "license": "MIT", + "repository": "HirziDevs/PteroStats", + "homepage": "https://pterostats.znproject.my.id", + "bugs": { + "email": "hirzidevs@gmail.com", + "url": "https://github.com/HirziDevs/PteroStats/issues" + }, + "scripts": { + "start": "node index.js" + }, + "dependencies": { + "axios": "^1.7.7", + "cli-color": "^2.0.4", + "discord.js": "^14.16.1", + "dotenv": "^16.4.5", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">=18" + } } \ No newline at end of file