generated from nhcarrigan/template
feat: add disclaimer, prompt for token as password for security
Node.js CI / Lint and Test (push) Failing after 22s
Node.js CI / Lint and Test (push) Failing after 22s
This commit is contained in:
@@ -4,13 +4,8 @@
|
|||||||
* @author Naomi Carrigan
|
* @author Naomi Carrigan
|
||||||
*/
|
*/
|
||||||
/* eslint-disable complexity, max-lines-per-function -- This is a chonky boi script. */
|
/* eslint-disable complexity, max-lines-per-function -- This is a chonky boi script. */
|
||||||
/**
|
|
||||||
* DISCORD SERVER STATS ANALYZER
|
import { password, confirm } from "@inquirer/prompts";
|
||||||
* * 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
interface Guild {
|
interface Guild {
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -130,9 +125,37 @@ const analyzeGuilds = (guilds: Array<Guild>): void => {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function getGuilds(): Promise<void> {
|
async function getGuilds(): Promise<void> {
|
||||||
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");
|
throw new Error("Missing TOKEN");
|
||||||
}
|
}
|
||||||
console.log("Fetching servers...");
|
console.log("Fetching servers...");
|
||||||
|
|||||||
Reference in New Issue
Block a user