From 51f2e5c7722cfe1ed2d4aec2fafed1b33b247077 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Fri, 19 Aug 2022 18:50:46 +0700 Subject: [PATCH] chore(RemoteAuth): Replace `colors.js` => `chalk` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Nguyễn Hồng Đức --- package.json | 1 - src/util/RemoteAuth.js | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 90c96df..e3f6dc6 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "axios": "^0.27.2", "bignumber.js": "^9.1.0", "chalk": "^4.1.2", - "colors": "^1.4.0", "discord-api-types": "^0.37.2", "form-data": "^4.0.0", "json-bigint": "^1.0.0", diff --git a/src/util/RemoteAuth.js b/src/util/RemoteAuth.js index 1b1812c..ee3b0d5 100644 --- a/src/util/RemoteAuth.js +++ b/src/util/RemoteAuth.js @@ -4,10 +4,10 @@ const crypto = require('crypto'); const EventEmitter = require('node:events'); const { setTimeout } = require('node:timers'); const { StringDecoder } = require('string_decoder'); +const chalk = require('chalk'); const { encode: urlsafe_b64encode } = require('safe-base64'); const WebSocket = require('ws'); const { randomUA } = require('./Constants'); -require('colors'); const baseURL = 'https://discord.com/ra/'; @@ -198,15 +198,15 @@ class DiscordAuthWebsocket extends EventEmitter { // eslint-disable-next-line no-unused-expressions this.options.failIfError ? this._throwError(new Error(message[0])) - : console.error(`[DiscordRemoteAuth] ERROR`.red, ...message); + : console.error(chalk.red(`[DiscordRemoteAuth] ERROR`), ...message); break; } case 'default': { - console.log(`[DiscordRemoteAuth]`.green, ...message); + console.log(chalk.green(`[DiscordRemoteAuth]`), ...message); break; } case 'debug': { - if (this.options.debug) console.log(`[DiscordRemoteAuth] DEBUG`.yellow, ...message); + if (this.options.debug) console.log(chalk.yellow(`[DiscordRemoteAuth] DEBUG`), ...message); break; } } @@ -380,12 +380,12 @@ class User { } prettyPrint(RemoteAuth) { let string = `\n`; - string += ` ${'User:'.bgBlue} `; + string += ` ${chalk.bgBlue('User:')} `; string += `${this.tag} (${this.id})\n`; - string += ` ${'Avatar URL:'.bgGreen} `; - string += `${this.avatarURL}\n`.cyan; - string += ` ${'Token:'.bgMagenta} `; - string += `${this.token ? this.token : 'Unknown'}`.red; + string += ` ${chalk.bgGreen('Avatar URL:')} `; + string += chalk.cyan(`${this.avatarURL}\n`); + string += ` ${chalk.bgMagenta('Token:')} `; + string += chalk.red(`${this.token ? this.token : 'Unknown'}`); RemoteAuth._logger('default', string); } }