From 52f31805d67c2592d6e504a8d0d7a79cc67e8e59 Mon Sep 17 00:00:00 2001 From: hgw Date: Mon, 2 Oct 2023 02:11:26 +0000 Subject: [PATCH] Create usersettings.json if it does not exist --- bot.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bot.js b/bot.js index 3787484..7817a43 100644 --- a/bot.js +++ b/bot.js @@ -128,4 +128,17 @@ bot.addListener('error', function(message) { }); console.log('[main] Starting Mercury'); -console.log('[main.irc] Connecting to '+config.irc.server+'/'+config.irc.port+' as '+config.irc.nickname) \ No newline at end of file +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); \ No newline at end of file