From 9ec788b71a34214106c21f7e94c7649bd88d8615 Mon Sep 17 00:00:00 2001 From: hgw Date: Mon, 2 Oct 2023 02:11:27 +0000 Subject: [PATCH] Fix crashing if user does not have a feed list and tries to add a feed --- commands/options.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/commands/options.js b/commands/options.js index e484dd5..a1bf75b 100644 --- a/commands/options.js +++ b/commands/options.js @@ -68,14 +68,19 @@ async function feed(nick, setting, value) { consoleLog('[options.feed] '+nick+' is adding '+value) await testFeed(value); var file = editJsonFile('/home/node/app/config/usersettings.json'); - var feedsArr = uconfig[nick].feeds - if (feedsArr.includes(value) == true) { - errorMessage("null", "ALREADYEXISTS", value) - } else { - file.append(nick+".feeds", value); - file.save(); - sendUpstream(value + ' added to your feed list') + try { + var feedsArr = uconfig[nick].feeds + if (feedsArr.includes(value) == true) { + errorMessage("null", "ALREADYEXISTS", value) + return; + } + } catch (e) { + consoleLog('[options.feed] No user feed list in usersettings.json, it will be made') } + file.append(nick+".feeds", value); + file.save(); + sendUpstream(value + ' added to your feed list') + } if (setting === 'list') { content = [];