diff --git a/src/discordas.ts b/src/discordas.ts index fa4d5b5f3f022e10f8724d71c5ed1e46d8d21a7f..be4b204cf177d799216fb1616a6c9c982417c2c6 100644 --- a/src/discordas.ts +++ b/src/discordas.ts @@ -133,7 +133,11 @@ async function run() { if (!port) { throw Error("Port not given in command line or config file"); } - config.applyConfig(yaml.safeLoad(fs.readFileSync(configPath, "utf8"))); + const readConfig = yaml.safeLoad(fs.readFileSync(configPath, "utf8")); + if (typeof readConfig !== "object") { + throw Error("Config is not of type object"); + } + config.applyConfig(readConfig); Log.Configure(config.logging); if (config.database.roomStorePath || config.database.userStorePath) { log.error("The keys 'roomStorePath' and/or 'userStorePath' is still defined in the config. " + diff --git a/tools/addbot.ts b/tools/addbot.ts index 2dda777537df95d53e6cbb8bdaed47175e89b2f6..335e1f19d51ee103099887b9708fe74151695308 100644 --- a/tools/addbot.ts +++ b/tools/addbot.ts @@ -62,6 +62,6 @@ const yamlConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")); if (yamlConfig === null) { console.error("You have an error in your discord config."); } - -const url = Util.GetBotLink(yamlConfig); +// We assume the config is well formed in this script +const url = Util.GetBotLink(yamlConfig as any); console.log(`Go to ${url} to invite the bot into a guild.`); diff --git a/tools/toolshelper.ts b/tools/toolshelper.ts index 1449f13aa0e5c7293c50ac170b7d54572df179e2..a0d571131664b02df6e68966f770a41d85b9486c 100644 --- a/tools/toolshelper.ts +++ b/tools/toolshelper.ts @@ -24,7 +24,8 @@ export class ToolsHelper { homeserverName: config.bridge.domain, homeserverUrl: config.bridge.homeserverUrl, port: 0, - registration, + // We assume the registration is well formed + registration: registration as any, }); const store = needsStore ? new DiscordStore(config.database ? config.database.filename : "discord.db") : null; diff --git a/tools/userClientTools.ts b/tools/userClientTools.ts index 0aadc222ea6f8f4e4aa73d43429e922de2e8e409..a6d923f7899075f7ebb8eba544735d94f2ac87fa 100644 --- a/tools/userClientTools.ts +++ b/tools/userClientTools.ts @@ -71,7 +71,7 @@ if (options.help || (options.add && options.remove) || !(options.add || options. process.exit(0); } -const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")); +const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig; const discordstore = new DiscordStore(config.database ? config.database : "discord.db"); discordstore.init().then(() => { log.info("Loaded database.");