fix: im done & handles users being goofy and missing some keys
This commit is contained in:
parent
0fdb7c51d9
commit
48a7c79620
@ -6,11 +6,13 @@
|
|||||||
import Interface from "./commands/Interface";
|
import Interface from "./commands/Interface";
|
||||||
import HttpServer from "./http/HttpServer";
|
import HttpServer from "./http/HttpServer";
|
||||||
import SRServer from "./server/kcp/SRServer";
|
import SRServer from "./server/kcp/SRServer";
|
||||||
|
import Banners from "./util/Banner";
|
||||||
import Logger from "./util/Logger";
|
import Logger from "./util/Logger";
|
||||||
import ProtoFactory from "./util/ProtoFactory"
|
import ProtoFactory from "./util/ProtoFactory"
|
||||||
|
|
||||||
const c = new Logger("CrepeSR");
|
const c = new Logger("CrepeSR");
|
||||||
c.log(`Starting CrepeSR...`);
|
c.log(`Starting CrepeSR...`);
|
||||||
|
Banners.config
|
||||||
ProtoFactory.init();
|
ProtoFactory.init();
|
||||||
Interface.start();
|
Interface.start();
|
||||||
HttpServer.getInstance().start();
|
HttpServer.getInstance().start();
|
||||||
|
@ -30,17 +30,17 @@ function r(...args: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function readConfig(): any {
|
function readConfig(): BannersConfig {
|
||||||
let config: BannersConfig;
|
let config: BannersConfig;
|
||||||
try {
|
try {
|
||||||
config = JSON.parse(r('../../banners.json'));
|
config = JSON.parse(r('../../banners.json'));
|
||||||
|
|
||||||
for(const [index, gachaBanner] of Object.entries(config)){
|
for(let [index, gachaBanner] of Object.entries(config)){
|
||||||
const missing = Object.keys(BANNERS[0]).filter(key => !gachaBanner.hasOwnProperty(key));
|
const missing = Object.keys(BANNERS[0]).filter(key => !gachaBanner.hasOwnProperty(key));
|
||||||
if (missing.length > 0) {
|
if (missing.length > 0) {
|
||||||
console.log(missing)
|
console.log(`Missing ${missing.join(', ')}, using default values. Backup of your older config: ${JSON.stringify(gachaBanner, null, 2)}`);
|
||||||
|
config[parseInt(index)] = BANNERS[0];
|
||||||
updateConfig(config);
|
updateConfig(config);
|
||||||
console.log(`Added missing banners keys: ${missing.join(', ')}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@ -51,7 +51,7 @@ function readConfig(): any {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateConfig(config: any) {
|
function updateConfig(config: BannersConfig) {
|
||||||
fs.writeFileSync('./banners.json', JSON.stringify(config, null, 2));
|
fs.writeFileSync('./banners.json', JSON.stringify(config, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user