diff --git a/src/bot.ts b/src/bot.ts index b50631833d1a19d21ba0048ccc878ccfd9bb50b6..74b050beab4da15999b84e6f1da92e2264e7beb3 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -97,7 +97,6 @@ export class DiscordBot { new MatrixEventProcessorOpts(this.config, this.bridge, this), ); this.channelSync = new ChannelSyncroniser(this.bridge, this.config, this); - this.userSync = new UserSyncroniser(this.bridge, this.config, this); // init vars this.sentMessages = []; @@ -137,6 +136,8 @@ export class DiscordBot { public async init(): Promise<void> { await this.store.init(); + // This uses userStore which needs to be accessed after the bridge has started. + this.userSync = new UserSyncroniser(this.bridge, this.config, this); await this.clientFactory.init(); } diff --git a/src/discordas.ts b/src/discordas.ts index 49f2ebf073ba49fe5f3554f16723c55fa369293e..bf15c03f0912775f2c876a42e9e80b80fdb251ad 100644 --- a/src/discordas.ts +++ b/src/discordas.ts @@ -148,8 +148,8 @@ async function run(port: number, fileConfig: DiscordBridgeConfig) { try { log.info("Initing store."); - await discordbot.init(); await bridge.run(port, config); + await discordbot.init(); log.info(`Started listening on port ${port}.`); log.info("Initing bot."); await discordbot.run();