diff options
author | Linnea Gräf <nea@nea.moe> | 2024-08-01 20:40:45 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-08-01 20:40:45 +0200 |
commit | 8649eb49663ca6e680a503d0e5f09111891804b3 (patch) | |
tree | 4694a5904a0ac5bad5922b765d274631fef24d69 | |
parent | 935b8f83764ae168994911d9b7b075f12a69a828 (diff) | |
download | mycelium-warning-master.tar.gz mycelium-warning-master.tar.bz2 mycelium-warning-master.zip |
-rw-r--r-- | app.js | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -48,25 +48,29 @@ for (i in profiles) { async function checkCollections() { for (i in profiles) { const p = profiles[i]; - const data = await getProfile(p); - console.log(data); - let collectionTotal = 0; - for (memberid in data.members) { - const member = data.members[memberid]; - const collectionOne = member.collection?.MYCEL; - if (collectionOne) collectionTotal += collectionOne; - } - const last = lastCollection[i]; - if (last !== collectionTotal) { - lastCollection[i] = collectionTotal; - lastCollectionGain[i] = Date.now(); - } - console.log("last: " + last); - console.log("current: " + collectionTotal); - if (Date.now() - lastCollectionGain[i] > WARN_AFTER * 1000) { - warn(p.ping) - .then((it) => it.json()) - .then(console.log, console.error); + try { + const data = await getProfile(p); + console.log(data); + let collectionTotal = 0; + for (memberid in data.members) { + const member = data.members[memberid]; + const collectionOne = member.collection?.MYCEL; + if (collectionOne) collectionTotal += collectionOne; + } + const last = lastCollection[i]; + if (last !== collectionTotal) { + lastCollection[i] = collectionTotal; + lastCollectionGain[i] = Date.now(); + } + console.log("last: " + last); + console.log("current: " + collectionTotal); + if (Date.now() - lastCollectionGain[i] > WARN_AFTER * 1000) { + warn(p.ping) + .then((it) => it.json()) + .then(console.log, console.error); + } + } catch (e) { + console.error("COULD NOTN CHECK PROFILES", e) } } } |