Create usersettings.json if it does not exist

This commit is contained in:
hgw 2023-10-02 02:11:26 +00:00
parent d573bec6ad
commit 52f31805d6

15
bot.js
View File

@ -128,4 +128,17 @@ bot.addListener('error', function(message) {
}); });
console.log('[main] Starting Mercury'); console.log('[main] Starting Mercury');
console.log('[main.irc] Connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname) fs.open('./config/usersettings.json','r',function(err, fd){
if (err) {
fs.writeFile('./config/usersettings.json', '', function(err) {
if(err) {
console.log(err);
}
console.log("usersettings.json did not exist, it has been created");
});
fs.writeFileSync('./config/usersettings.json', "\{\n\}")
} else {
console.log("usersettings.json exists, continuing");
}
});
console.log('[main.irc] Connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname);