summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-11-06 18:59:31 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-11-06 18:59:31 +1100
commit72faa449e048ad192b51de8fa1d49750b23c236c (patch)
treea2e9522401d36a21abb870ae5ef9862374c7e1ee /src
parentFix 404 handler (diff)
downloadserver-72faa449e048ad192b51de8fa1d49750b23c236c.tar.xz
Await some rabbitmq methods, don't reset some config values on start
Diffstat (limited to 'src')
-rw-r--r--src/bundle/Server.ts58
-rw-r--r--src/util/util/Event.ts16
2 files changed, 37 insertions, 37 deletions
diff --git a/src/bundle/Server.ts b/src/bundle/Server.ts
index 2bc45f84..dbd57abf 100644
--- a/src/bundle/Server.ts
+++ b/src/bundle/Server.ts
@@ -31,35 +31,35 @@ async function main() {
 	await initDatabase();
 	await Config.init();
 	await BannedWords.init();
-	// only set endpointPublic, if not already set
-	await Config.set({
-		cdn: {
-			endpointClient: "${location.host}",
-			endpointPrivate: `http://localhost:${port}`,
-		},
-		gateway: {
-			endpointClient:
-				'${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
-			endpointPrivate: `ws://localhost:${port}`,
-			...(!Config.get().gateway.endpointPublic && {
-				endpointPublic: `ws://localhost:${port}`,
-			}),
-		},
-		// regions: {
-		// 	default: "fosscord",
-		// 	useDefaultAsOptimal: true,
-		// 	available: [
-		// 		{
-		// 			id: "fosscord",
-		// 			name: "Fosscord",
-		// 			endpoint: "slowcord.maddy.k.vu:3004",
-		// 			vip: false,
-		// 			custom: false,
-		// 			deprecated: false,
-		// 		},
-		// 	],
-		// },
-	} as any);
+	// // only set endpointPublic, if not already set
+	// await Config.set({
+	// 	cdn: {
+	// 		endpointClient: "${location.host}",
+	// 		endpointPrivate: `http://localhost:${port}`,
+	// 	},
+	// 	gateway: {
+	// 		endpointClient:
+	// 			'${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
+	// 		endpointPrivate: `ws://localhost:${port}`,
+	// 		...(!Config.get().gateway.endpointPublic && {
+	// 			endpointPublic: `ws://localhost:${port}`,
+	// 		}),
+	// 	},
+	// 	regions: {
+	// 		default: "fosscord",
+	// 		useDefaultAsOptimal: true,
+	// 		available: [
+	// 			{
+	// 				id: "fosscord",
+	// 				name: "Fosscord",
+	// 				endpoint: "slowcord.maddy.k.vu:3004",
+	// 				vip: false,
+	// 				custom: false,
+	// 				deprecated: false,
+	// 			},
+	// 		],
+	// 	},
+	// } as any);
 
 	//Sentry
 	if (Config.get().sentry.enabled) {
diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts
index c81de951..b7fddd3b 100644
--- a/src/util/util/Event.ts
+++ b/src/util/util/Event.ts
@@ -66,7 +66,7 @@ export async function listenEvent(
 	opts?: ListenEventOpts,
 ) {
 	if (RabbitMQ.connection) {
-		return rabbitListen(
+		return await rabbitListen(
 			// @ts-ignore
 			opts?.channel || RabbitMQ.channel,
 			event,
@@ -74,7 +74,7 @@ export async function listenEvent(
 			{ acknowledge: opts?.acknowledge },
 		);
 	} else if (process.env.EVENT_TRANSMISSION === "process") {
-		const cancel = () => {
+		const cancel = async () => {
 			process.removeListener("message", listener);
 			process.setMaxListeners(process.getMaxListeners() - 1);
 		};
@@ -92,7 +92,7 @@ export async function listenEvent(
 		return cancel;
 	} else {
 		const listener = (opts: any) => callback({ ...opts, cancel });
-		const cancel = () => {
+		const cancel = async () => {
 			events.removeListener(event, listener);
 			events.setMaxListeners(events.getMaxListeners() - 1);
 		};
@@ -115,13 +115,13 @@ async function rabbitListen(
 		autoDelete: true,
 	});
 
-	const cancel = () => {
-		channel.cancel(q.queue);
-		channel.unbindQueue(q.queue, id, "");
+	const cancel = async () => {
+		await channel.cancel(q.queue);
+		await channel.unbindQueue(q.queue, id, "");
 	};
 
-	channel.bindQueue(q.queue, id, "");
-	channel.consume(
+	await channel.bindQueue(q.queue, id, "");
+	await channel.consume(
 		q.queue,
 		(opts) => {
 			if (!opts) return;