mirror of
https://github.com/a-sync/game-server-watcher.git
synced 2026-04-05 09:03:59 -04:00
make it make sense
😵
This commit is contained in:
@@ -17,15 +17,15 @@ interface GameServerDb {
|
|||||||
|
|
||||||
const db = await JSONPreset<GameServerDb>(DATA_PATH + 'servers.json', { population: {} });
|
const db = await JSONPreset<GameServerDb>(DATA_PATH + 'servers.json', { population: {} });
|
||||||
|
|
||||||
export async function initDb() {
|
export async function initPopulationDb() {
|
||||||
await db.read();
|
await db.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function saveDb() {
|
export async function savePopulationDb() {
|
||||||
try {
|
try {
|
||||||
return await db.write();
|
return await db.write();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error('gs.saveDb', e.message || e);
|
console.error('gs.savePopulationDb', e.message || e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { JSONPreset } from 'lowdb/node';
|
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 discordBot from './discord-bot.js';
|
||||||
import * as telegramBot from './telegram-bot.js';
|
import * as telegramBot from './telegram-bot.js';
|
||||||
import * as slackBot from './slack-bot.js';
|
import * as slackBot from './slack-bot.js';
|
||||||
@@ -95,7 +95,7 @@ export class Watcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await Promise.allSettled(promises);
|
await Promise.allSettled(promises);
|
||||||
await saveDb();
|
await savePopulationDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
@@ -104,7 +104,7 @@ export class Watcher {
|
|||||||
if (DISCORD_BOT_TOKEN) await discordBot.init(DISCORD_BOT_TOKEN);
|
if (DISCORD_BOT_TOKEN) await discordBot.init(DISCORD_BOT_TOKEN);
|
||||||
if (TELEGRAM_BOT_TOKEN) await telegramBot.init(TELEGRAM_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);
|
if (SLACK_BOT_TOKEN && SLACK_APP_TOKEN) await slackBot.init(SLACK_BOT_TOKEN, SLACK_APP_TOKEN);
|
||||||
await initDb();
|
await initPopulationDb();
|
||||||
|
|
||||||
await db.read();
|
await db.read();
|
||||||
this.servers.length = 0;
|
this.servers.length = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user