message: real pause for ghost joining
diff: @@ -59,7 +59,8 @@ if (options.help) {
  const yamlConfig = yaml.safeLoad(fs.readFileSync("./discord-registration.yaml", "utf8"));
  const registration = AppServiceRegistration.fromObject(yamlConfig);
  -const config: DiscordBridgeConfig = yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig;
  +const config = new DiscordBridgeConfig();
  +config.ApplyConfig(yaml.safeLoad(fs.readFileSync(options.config, "utf8")) as DiscordBridgeConfig);
  if (registration === null) {
  throw new Error("Failed to parse registration file");
  @@ -107,7 +108,9 @@ bridge.loadDatabases().catch((e) => {
  });
  }).then((clientTmp: any) => {
  client = clientTmp;
  - const promiseList = [];
  + let promiseChain: Bluebird<any> = Bluebird.resolve();
  +
  + let delay = config.limits.roomGhostJoinDelay;
  client.guilds.forEach((guild) => {
  guild.channels.forEach((channel) => {
  if (channel.type !== "text") {
  @@ -117,7 +120,8 @@ bridge.loadDatabases().catch((e) => {
  if (member.id === client.user.id) {
  return;
  }
  - promiseList.push(Bluebird.each(discordbot.GetRoomIdsFromChannel(channel), (room) => {
  + promiseChain = promiseChain.return(Bluebird.delay(delay).then(() => {
  + return Bluebird.each(discordbot.GetRoomIdsFromChannel(channel), (room) => {
  let currentSchedule = JOIN_ROOM_SCHEDULE[0];
  const doJoin = () => Util.DelayedPromise(currentSchedule).then(() => {
  userSync.EnsureJoin(member, room);
  @@ -135,11 +139,17 @@ bridge.loadDatabases().catch((e) => {
  }
  };
  return doJoin().catch(errorHandler);
  + }).catch((err) => {
  + log.warn("Ghostfix", `No associated matrix rooms for discord room ${channel.id}`);
  + });
  }));
  + delay += config.limits.roomGhostJoinDelay;
  });
  });
  });
  - return Bluebird.all(promiseList);
  + return promiseChain;
  +}).catch((err) => {
  + log.error("Ghostfix", err);
  }).then(() => {
  process.exit(0);
  });
  