make it make sense

😵
This commit is contained in:
Smith
2024-03-11 11:14:58 +01:00
parent 3ff6384360
commit 4ad9fbb608
2 changed files with 6 additions and 6 deletions

View File

@@ -17,15 +17,15 @@ interface GameServerDb {
const db = await JSONPreset<GameServerDb>(DATA_PATH + 'servers.json', { population: {} });
export async function initDb() {
export async function initPopulationDb() {
await db.read();
}
export async function saveDb() {
export async function savePopulationDb() {
try {
return await db.write();
} catch (e: any) {
console.error('gs.saveDb', e.message || e);
console.error('gs.savePopulationDb', e.message || e);
}
}

View File

@@ -1,6 +1,6 @@
import fs from 'node:fs';
import { JSONPreset } from 'lowdb/node';
import { GameServer, initDb, saveDb } from './game-server.js';
import { GameServer, initPopulationDb, savePopulationDb } from './game-server.js';
import * as discordBot from './discord-bot.js';
import * as telegramBot from './telegram-bot.js';
import * as slackBot from './slack-bot.js';
@@ -95,7 +95,7 @@ export class Watcher {
}
await Promise.allSettled(promises);
await saveDb();
await savePopulationDb();
}
async start() {
@@ -104,7 +104,7 @@ export class Watcher {
if (DISCORD_BOT_TOKEN) await discordBot.init(DISCORD_BOT_TOKEN);
if (TELEGRAM_BOT_TOKEN) await telegramBot.init(TELEGRAM_BOT_TOKEN);
if (SLACK_BOT_TOKEN && SLACK_APP_TOKEN) await slackBot.init(SLACK_BOT_TOKEN, SLACK_APP_TOKEN);
await initDb();
await initPopulationDb();
await db.read();
this.servers.length = 0;