mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-06-22 14:14:20 +00:00
Added Warn and Ban Commands, Added Logging, and Much More
This commit is contained in:
parent
d89de72e08
commit
86adac3f08
33 changed files with 2200 additions and 204 deletions
23
src/util/configLoader.ts
Normal file
23
src/util/configLoader.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Config } from '../types/ConfigTypes.js';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
export function loadConfig(): Config {
|
||||
try {
|
||||
const configPath = path.join(process.cwd(), './config.json');
|
||||
const configFile = fs.readFileSync(configPath, 'utf8');
|
||||
const config: Config = JSON.parse(configFile);
|
||||
|
||||
const requiredFields = ['token', 'clientId', 'guildId'];
|
||||
for (const field of requiredFields) {
|
||||
if (!config[field as keyof Config]) {
|
||||
throw new Error(`Missing required config field: ${field}`);
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
} catch (error) {
|
||||
console.error('Failed to load config:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue