summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/benchmark/connections.js2
-rw-r--r--scripts/client.js50
-rw-r--r--scripts/rights.js4
-rw-r--r--scripts/schema.js14
-rw-r--r--scripts/stresstest/src/login/index.js4
-rw-r--r--scripts/stresstest/src/message/send.js19
-rw-r--r--scripts/stresstest/src/register/index.js10
7 files changed, 65 insertions, 38 deletions
diff --git a/scripts/benchmark/connections.js b/scripts/benchmark/connections.js
index 515f76e9..1a30d49f 100644
--- a/scripts/benchmark/connections.js
+++ b/scripts/benchmark/connections.js
@@ -48,7 +48,7 @@ function connect() {
 							token,
 							properties: {},
 						},
-					})
+					}),
 				);
 
 				break;
diff --git a/scripts/client.js b/scripts/client.js
index e73bc7ee..ed1a94b9 100644
--- a/scripts/client.js
+++ b/scripts/client.js
@@ -8,21 +8,21 @@ const BASE_URL = "https://discord.com";
 
 // Manual for now
 const INDEX_SCRIPTS = [
-	"83ace7450e110d16319e",	// 50
-	"e02290aaa8dac5d195c2",	// 1
-	"4f3b3c576b879a5f75d1",	// 0?
-	"699456246fdfe7589855",	// ~4500.
+	"83ace7450e110d16319e", // 50
+	"e02290aaa8dac5d195c2", // 1
+	"4f3b3c576b879a5f75d1", // 0?
+	"699456246fdfe7589855", // ~4500.
 ];
 
 const doPatch = (content) => {
 	//remove nitro references
 	content = content.replace(/Discord Nitro/g, "Fosscord Premium");
-	content = content.replace(/"Nitro"/g, "\"Premium\"");
+	content = content.replace(/"Nitro"/g, '"Premium"');
 	content = content.replace(/Nitro /g, "Premium ");
 	content = content.replace(/ Nitro/g, " Premium");
 	content = content.replace(/\[Nitro\]/g, "[Premium]");
 	content = content.replace(/\*Nitro\*/g, "*Premium*");
-	content = content.replace(/\"Nitro \. /g, "\"Premium. ");
+	content = content.replace(/\"Nitro \. /g, '"Premium. ');
 
 	//remove discord references
 	content = content.replace(/ Discord /g, " Fosscord ");
@@ -35,11 +35,11 @@ const doPatch = (content) => {
 	content = content.replace(/\*Discord\*/g, "*Fosscord*");
 
 	//server -> guild
-	content = content.replace(/"Server"/g, "\"Guild\"");
-	content.replaceAll("server.\"", "guild.\"");
+	content = content.replace(/"Server"/g, '"Guild"');
+	content.replaceAll('server."', 'guild."');
 	content.replaceAll(" server ", " guild ");
 	content.replaceAll(" Server ", " Guild ");
-	content.replaceAll("\"Server", "\"Guild");
+	content.replaceAll('"Server', '"Guild');
 
 	// //change some vars
 	// content = content.replace('dsn: "https://fa97a90475514c03a42f80cd36d147c4@sentry.io/140984"', "dsn: (/true/.test(localStorage.sentryOptIn)?'https://6bad92b0175d41a18a037a73d0cff282@sentry.thearcanebrony.net/12':'')");
@@ -52,8 +52,14 @@ const doPatch = (content) => {
 	// content = content.replace('width: n, height: o, viewBox: "0 0 28 20"', 'width: 48, height: 48, viewBox: "0 0 48 48"');
 
 	//save some time on load resolving asset urls...
-	content = content.replaceAll('e.exports = n.p + "', 'e.exports = "/assets/');
-	content = content.replaceAll('e.exports = r.p + "', 'e.exports = "/assets/');
+	content = content.replaceAll(
+		'e.exports = n.p + "',
+		'e.exports = "/assets/',
+	);
+	content = content.replaceAll(
+		'e.exports = r.p + "',
+		'e.exports = "/assets/',
+	);
 
 	return content;
 };
@@ -66,7 +72,7 @@ const processFile = async (name) => {
 
 	await fs.writeFile(path.join(CACHE_PATH, `${name}.js`), text);
 
-	return [...new Set(text.match((/[A-Fa-f0-9]{20}/g)))];
+	return [...new Set(text.match(/[A-Fa-f0-9]{20}/g))];
 };
 
 (async () => {
@@ -83,7 +89,9 @@ const processFile = async (name) => {
 
 		process.stdout.clearLine(0);
 		process.stdout.cursorTo(0);
-		process.stdout.write(`Scraping asset ${asset}. Remaining: ${INDEX_SCRIPTS.length}`);
+		process.stdout.write(
+			`Scraping asset ${asset}. Remaining: ${INDEX_SCRIPTS.length}`,
+		);
 
 		const newAssets = await processFile(asset);
 		assets.push(...newAssets);
@@ -103,15 +111,21 @@ const processFile = async (name) => {
 		}
 
 		while (rates.length > 20) rates.shift();
-		const averageRate = rates.length ? rates.reduce((prev, curr) => prev + curr) / rates.length : 1;
-		const finishTime = (averageRate * (assets.length - i));
+		const averageRate = rates.length
+			? rates.reduce((prev, curr) => prev + curr) / rates.length
+			: 1;
+		const finishTime = averageRate * (assets.length - i);
 
 		process.stdout.clearLine(0);
 		process.stdout.cursorTo(0);
 		process.stdout.write(
 			`Caching asset ${asset}. ` +
-			`${i}/${assets.length - 1} = ${Math.floor((i / (assets.length - 1)) * 100)}% ` +
-			`Finish at: ${new Date(Date.now() + finishTime).toLocaleTimeString()}`
+				`${i}/${assets.length - 1} = ${Math.floor(
+					(i / (assets.length - 1)) * 100,
+				)}% ` +
+				`Finish at: ${new Date(
+					Date.now() + finishTime,
+				).toLocaleTimeString()}`,
 		);
 
 		await processFile(asset);
@@ -122,4 +136,4 @@ const processFile = async (name) => {
 	}
 
 	console.log(`\nDone`);
-})();
\ No newline at end of file
+})();
diff --git a/scripts/rights.js b/scripts/rights.js
index a4eb0b31..d0d1e163 100644
--- a/scripts/rights.js
+++ b/scripts/rights.js
@@ -1,4 +1,4 @@
-require('module-alias/register');
+require("module-alias/register");
 const { Rights } = require("..");
 
 const allRights = new Rights(1).bitfield;
@@ -18,4 +18,4 @@ discordLike -= Rights.FLAGS.BYPASS_RATE_LIMITS;
 discordLike -= Rights.FLAGS.CREDITABLE;
 discordLike -= Rights.FLAGS.MANAGE_GUILD_DIRECTORY;
 discordLike -= Rights.FLAGS.SEND_BACKDATED_EVENTS;
-console.log(`Discord.com-like rights:`, discordLike);
\ No newline at end of file
+console.log(`Discord.com-like rights:`, discordLike);
diff --git a/scripts/schema.js b/scripts/schema.js
index de062d63..90a346c9 100644
--- a/scripts/schema.js
+++ b/scripts/schema.js
@@ -11,10 +11,10 @@ const settings = {
 	excludePrivate: true,
 	defaultNumberType: "integer",
 	noExtraProps: true,
-	defaultProps: false
+	defaultProps: false,
 };
 const compilerOptions = {
-	strictNullChecks: true
+	strictNullChecks: true,
 };
 const Excluded = [
 	"DefaultSchema",
@@ -47,11 +47,17 @@ function modify(obj) {
 }
 
 function main() {
-	const program = TJS.programFromConfig("tsconfig.json")
+	const program = TJS.programFromConfig("tsconfig.json");
 	const generator = TJS.buildGenerator(program, settings);
 	if (!generator || !program) return;
 
-	let schemas = generator.getUserSymbols().filter((x) => (x.endsWith("Schema") || x.endsWith("Response")) && !Excluded.includes(x));
+	let schemas = generator
+		.getUserSymbols()
+		.filter(
+			(x) =>
+				(x.endsWith("Schema") || x.endsWith("Response")) &&
+				!Excluded.includes(x),
+		);
 	console.log(schemas);
 
 	var definitions = {};
diff --git a/scripts/stresstest/src/login/index.js b/scripts/stresstest/src/login/index.js
index 96603652..291e2b8b 100644
--- a/scripts/stresstest/src/login/index.js
+++ b/scripts/stresstest/src/login/index.js
@@ -6,12 +6,12 @@ async function login(account) {
 	var body = {
 		fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw",
 		login: account.email,
-		password: account.password
+		password: account.password,
 	};
 	var x = await fetch(config.url + "/auth/login", {
 		method: "POST",
 		headers: { "Content-Type": "application/json" },
-		body: JSON.stringify(body)
+		body: JSON.stringify(body),
 	});
 	console.log(x);
 	x = await x.json();
diff --git a/scripts/stresstest/src/message/send.js b/scripts/stresstest/src/message/send.js
index d21560d7..1e5ea062 100644
--- a/scripts/stresstest/src/message/send.js
+++ b/scripts/stresstest/src/message/send.js
@@ -6,16 +6,19 @@ async function sendMessage(account) {
 	var body = {
 		fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw",
 		content: "Test",
-		tts: false
+		tts: false,
 	};
-	var x = await fetch(config.url + "/channels/" + config["text-channel"] + "/messages", {
-		method: "POST",
-		headers: {
-			"Content-Type": "application/json",
-			Authorization: account.token
+	var x = await fetch(
+		config.url + "/channels/" + config["text-channel"] + "/messages",
+		{
+			method: "POST",
+			headers: {
+				"Content-Type": "application/json",
+				Authorization: account.token,
+			},
+			body: JSON.stringify(body),
 		},
-		body: JSON.stringify(body)
-	});
+	);
 	console.log(x);
 	x = await x.json();
 	console.log(x);
diff --git a/scripts/stresstest/src/register/index.js b/scripts/stresstest/src/register/index.js
index 86f908cd..38089dc7 100644
--- a/scripts/stresstest/src/register/index.js
+++ b/scripts/stresstest/src/register/index.js
@@ -4,7 +4,11 @@ var config = require("../../config.json");
 module.exports = generate;
 async function generate() {
 	var mail = (Math.random() + 10).toString(36).substring(2);
-	mail = mail + "." + (Math.random() + 10).toString(36).substring(2) + "@stresstest.com";
+	mail =
+		mail +
+		"." +
+		(Math.random() + 10).toString(36).substring(2) +
+		"@stresstest.com";
 	var password =
 		(Math.random() * 69).toString(36).substring(-7) +
 		(Math.random() * 69).toString(36).substring(-7) +
@@ -20,12 +24,12 @@ async function generate() {
 		consent: true,
 		date_of_birth: "2000-04-04",
 		gift_code_sku_id: null,
-		captcha_key: null
+		captcha_key: null,
 	};
 	var x = await fetch(config.url + "/auth/register", {
 		method: "POST",
 		headers: { "Content-Type": "application/json" },
-		body: JSON.stringify(body)
+		body: JSON.stringify(body),
 	});
 	console.log(x);
 	x = await x.json();