From b5859ab6b3e917b801b6fddbc57378355470cb41 Mon Sep 17 00:00:00 2001
From: Will Hunt <willh@matrix.org>
Date: Tue, 1 Dec 2020 11:12:50 +0000
Subject: [PATCH] Fix port bug

---
 src/discordas.ts | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/discordas.ts b/src/discordas.ts
index 190575d..b6c5225 100644
--- a/src/discordas.ts
+++ b/src/discordas.ts
@@ -129,10 +129,6 @@ async function run() {
     }
 
     const config = new DiscordBridgeConfig();
-    const port = opts.port || config.bridge.port;
-    if (!port) {
-        throw Error("Port not given in command line or config file");
-    }
     const readConfig = yaml.safeLoad(fs.readFileSync(configPath, "utf8"));
     if (typeof readConfig !== "object") {
         throw Error("Config is not of type object");
@@ -140,6 +136,10 @@ async function run() {
     config.applyConfig(readConfig);
     config.applyEnvironmentOverrides(process.env);
     Log.Configure(config.logging);
+    const port = opts.port || config.bridge.port;
+    if (!port) {
+        throw Error("Port not given in command line or config file");
+    }
     if (config.database.roomStorePath || config.database.userStorePath) {
         log.error("The keys 'roomStorePath' and/or 'userStorePath' is still defined in the config. " +
                   "Please see docs/bridge-migrations.md on " +
-- 
GitLab