From bb3d582f61694eeba5c1aff018726ac3c0626b49 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Mon, 21 Mar 2022 10:56:51 +0700 Subject: [PATCH] Clear console.log, checkUpdate in ClientOptions --- package.json | 3 ++- src/client/websocket/handlers/READY.js | 27 +++++++++++++++++++++++++- src/util/Options.js | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 521a260..82845d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord.js-selfbot-v13", - "version": "0.1.3", + "version": "0.1.4", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "main": "./src/index.js", "types": "./typings/index.d.ts", @@ -45,6 +45,7 @@ "@sapphire/snowflake": "^3.2.0", "@types/ws": "^8.5.2", "axios": "^0.26.1", + "chalk": "^4.1.2", "discord-api-types": "^0.27.3", "discord.js": "^13.6.0", "form-data": "^4.0.0", diff --git a/src/client/websocket/handlers/READY.js b/src/client/websocket/handlers/READY.js index f7db407..d1e5975 100644 --- a/src/client/websocket/handlers/READY.js +++ b/src/client/websocket/handlers/READY.js @@ -3,10 +3,35 @@ const ClientApplication = require('../../../structures/ClientApplication'); const User = require('../../../structures/User'); let ClientUser; +const chalk = require('chalk'); +const axios = require('axios'); +const Discord = require('discord.js-selfbot-v13'); + +const checkUpdate = async () => { + const res_ = await axios.get( + `https://registry.npmjs.com/${encodeURIComponent('discord.js-selfbot-v13')}`, + ); + const lastest_tag = res_.data['dist-tags'].latest; + // Checking if the package is outdated + // Stable version + if (lastest_tag !== Discord.version) { + return console.log(`${chalk.yellowBright( + '[WARNING]', + )} New Discord.js-selfbot-v13 Stable version. +${chalk.redBright(Discord.version)} => ${chalk.greenBright(lastest_tag)}`); + } + return console.log( + `${chalk.greenBright( + '[OK]', + )} Discord.js-selfbot-v13 [Stable] is up to date. Version: ${chalk.blueBright( + Discord.version, + )}`, + ); +}; module.exports = (client, { d: data }, shard) => { // console.log(data); - + if (client.options.checkUpdate) checkUpdate(); client.session_id = data.session_id; if (client.user) { client.user._patch(data.user); diff --git a/src/util/Options.js b/src/util/Options.js index 3fd2b28..3299984 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -128,6 +128,7 @@ class Options extends null { scheduledEvent: 'https://discord.com/events', }, jsonTransformer: (object) => JSONBig.stringify(object), + checkUpdate: true, }; }