11import YAML from "yaml" ;
22import fs from "fs" ;
3- import { Logger } from "./logger.js" ;
4- import { LoggingAction } from "../enums/loggingTypes.js" ;
53import { botData } from "./version.js" ;
64import colors from "colors" ;
75import { DisBotConfigData } from "../types/config.js" ;
@@ -11,10 +9,10 @@ colors.enable();
119export let Config : DisBotConfigData
1210
1311export async function configStartup ( ) {
14- const fileCheck = fs . existsSync ( ` ${ process . cwd ( ) } /config.yml` ) ;
12+ const fileCheck = fs . existsSync ( process . env . CONFIG_PATH ) ;
1513 let content : string
1614 if ( fileCheck ) {
17- const fileContent = fs . readFileSync ( ` ${ process . cwd ( ) } /config.yml` ) ;
15+ const fileContent = fs . readFileSync ( process . env . CONFIG_PATH ) ;
1816 content = fileContent . toString ( ) ;
1917 }
2018 if ( ! fileCheck || ! content ) {
@@ -76,8 +74,6 @@ export async function configStartup() {
7674 DbName : "" ,
7775 } ,
7876 Logging : {
79- BotLoggingApiPort : 0 ,
80- BotLoggingPassword : "" ,
8177 ErrorWebhook : "" ,
8278 BotLogger : "" ,
8379 } ,
@@ -86,41 +82,19 @@ export async function configStartup() {
8682 } ;
8783
8884 fs . writeFileSync (
89- ` ${ process . cwd ( ) } /config.yml` ,
85+ process . env . CONFIG_PATH ,
9086 YAML . stringify ( configData )
9187 ) ;
9288 }
9389
94- const file = fs . readFileSync ( ` ${ process . cwd ( ) } /config.yml` , "utf8" ) ;
90+ const file = fs . readFileSync ( process . env . CONFIG_PATH , "utf8" ) ;
9591 const ymlData = YAML . parse ( file ) ;
9692 Config = ymlData ;
9793
98- Logger . info ( {
99- guildId : "0" ,
100- userId : "0" ,
101- channelId : "0" ,
102- messageId : "0" ,
103- timestamp : new Date ( ) . toISOString ( ) ,
104- level : "info" ,
105- label : "Config" ,
106- message : `DisBot Config is loaded and exported!` ,
107- botType : "Unknown" ,
108- action : LoggingAction . Other ,
109- } ) ;
94+ console . log ( "DisBot Config is loaded and exported! (Logger, Startup, Bot)" )
11095
11196 if ( Config . CONFIG_VERSION != botData . configVersion ) {
112- Logger . error ( {
113- guildId : "0" ,
114- userId : "0" ,
115- channelId : "0" ,
116- messageId : "0" ,
117- timestamp : new Date ( ) . toISOString ( ) ,
118- level : "error" ,
119- label : "Config" ,
120- message : `Please recreate your Bot Config` . red ,
121- botType : "Unknown" ,
122- action : LoggingAction . Other ,
123- } ) ;
97+ console . error ( `Please recreate your Bot Config` . red )
12498 process . exit ( 0 ) ;
12599 }
126100}
0 commit comments