From 128c7c2f963a041f3785c22dc3fc3d3fedbd51fa Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Wed, 3 Dec 2025 14:01:02 -0800 Subject: [PATCH] feat: add disclaimer, prompt for token as password for security --- src/discord/guildCount.ts | 41 ++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/discord/guildCount.ts b/src/discord/guildCount.ts index b4122eb..13cff3a 100644 --- a/src/discord/guildCount.ts +++ b/src/discord/guildCount.ts @@ -4,13 +4,8 @@ * @author Naomi Carrigan */ /* eslint-disable complexity, max-lines-per-function -- This is a chonky boi script. */ -/** - * DISCORD SERVER STATS ANALYZER - * * Instructions: - * 1. Get your User Token (Open Discord in Browser -> F12 -> Network Tab -> Type a message -> Look for "authorization" in request headers). - * 2. Set it in the .env file as TOKEN. - * 3. Run with: node discord_stats.js. - */ + +import { password, confirm } from "@inquirer/prompts"; interface Guild { name?: string; @@ -130,9 +125,37 @@ const analyzeGuilds = (guilds: Array): void => { * */ async function getGuilds(): Promise { - const token = process.env.TOKEN; + console.log( + `WARNING! This script requires your user token. Because of this, you MUST take these into consideration:`, + ); + console.log( + `1. DO NOT SHARE YOUR TOKEN WITH ANYONE. Your token can be used to impersonate your account, and can only be changed by rotating your account password.`, + ); + console.log( + `2. THIS SCRIPT IS CONSIDERED SELF BOTTING. Running this is a violation of Discord's Terms of Service. DO SO AT YOUR OWN RISK!`, + ); + console.log( + `3. Naomi Carrigan, NHCarrigan, its associates, and its affiliates are not responsible for any actions taken by you using this script.`, + ); + const confirmed = await confirm({ + message: + "I understand these risks, agree to the terms, and want to continue.", + }); + if (!confirmed) { + throw new Error("User did not confirm the terms."); + } + const token = await password({ + mask: true, + message: "Please enter your user token:", + validate: (value) => { + if (value === "") { + return "Token is required"; + } + return true; + }, + }); - if (token === undefined) { + if (token === "") { throw new Error("Missing TOKEN"); } console.log("Fetching servers...");