mirror of
https://github.com/YuzuZensai/Kiroku.git
synced 2026-01-30 20:34:28 +00:00
First releases
This commit is contained in:
42
src/providers/ConfigProvider.ts
Normal file
42
src/providers/ConfigProvider.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import fs from 'fs';
|
||||
import { Client, Events, GatewayIntentBits } from 'discord.js';
|
||||
|
||||
export interface Config {
|
||||
global: {
|
||||
discord_guild_id?: string;
|
||||
discord_bot_token?: string;
|
||||
steam_api_key?: string;
|
||||
};
|
||||
users: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
class ConfigProvider {
|
||||
private config: Config = {
|
||||
global: {},
|
||||
users: {}
|
||||
};
|
||||
private ready = false;
|
||||
|
||||
constructor() {
|
||||
try {
|
||||
let data = fs.readFileSync('./config.json', 'utf8');
|
||||
this.config = JSON.parse(data);
|
||||
this.ready = true;
|
||||
} catch (err) {
|
||||
console.error('[ConfigProvider]', err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public getConfig(): Config {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public isReady(): boolean {
|
||||
return this.ready;
|
||||
}
|
||||
}
|
||||
|
||||
export default new ConfigProvider();
|
||||
Reference in New Issue
Block a user