feat: Introduce dynamic JSON-based configuration for game settings and command toggling via a new admin command.
This commit is contained in:
20
src/lib/configManager.ts
Normal file
20
src/lib/configManager.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { KyokoClient } from '@/lib/KyokoClient';
|
||||
|
||||
const configPath = join(process.cwd(), 'src', 'config', 'game.json');
|
||||
|
||||
export const configManager = {
|
||||
toggleCommand: (commandName: string, enabled: boolean) => {
|
||||
const raw = readFileSync(configPath, 'utf-8');
|
||||
const data = JSON.parse(raw);
|
||||
|
||||
if (!data.commands) {
|
||||
data.commands = {};
|
||||
}
|
||||
|
||||
data.commands[commandName] = enabled;
|
||||
|
||||
writeFileSync(configPath, JSON.stringify(data, null, 4));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user