Fix crashing if user does not have a feed list and tries to add a feed

This commit is contained in:
hgw 2023-10-02 02:11:27 +00:00
parent 2ec02130b0
commit 9ec788b71a

View File

@ -68,14 +68,19 @@ async function feed(nick, setting, value) {
consoleLog('[options.feed] '+nick+' is adding '+value) consoleLog('[options.feed] '+nick+' is adding '+value)
await testFeed(value); await testFeed(value);
var file = editJsonFile('/home/node/app/config/usersettings.json'); var file = editJsonFile('/home/node/app/config/usersettings.json');
try {
var feedsArr = uconfig[nick].feeds var feedsArr = uconfig[nick].feeds
if (feedsArr.includes(value) == true) { if (feedsArr.includes(value) == true) {
errorMessage("null", "ALREADYEXISTS", value) errorMessage("null", "ALREADYEXISTS", value)
} else { return;
}
} catch (e) {
consoleLog('[options.feed] No user feed list in usersettings.json, it will be made')
}
file.append(nick+".feeds", value); file.append(nick+".feeds", value);
file.save(); file.save();
sendUpstream(value + ' added to your feed list') sendUpstream(value + ' added to your feed list')
}
} }
if (setting === 'list') { if (setting === 'list') {
content = []; content = [];