fix unavailableOC

This commit is contained in:
2026-01-10 08:30:34 -05:00
parent 5270fbccf7
commit 72aabc83bd

View File

@@ -6,7 +6,7 @@ module.exports = async (client, torn, config) => {
const state = require('../state.json'); const state = require('../state.json');
let factionMaxCrime = 0; let factionMaxCrime = 0;
const crimeLevel = (await torn.faction.upgrades()).core.upgrades.find(upgrade => upgrade.name.startsWith("Organized Crimes")).level const crimeLevel = (await torn.faction.upgrades()).upgrades.core.upgrades.find(upgrade => upgrade.name.startsWith("Organized Crimes")).level
switch (crimeLevel) { switch (crimeLevel) {
case 1: case 1:
factionMaxCrime = 2 factionMaxCrime = 2
@@ -54,7 +54,7 @@ module.exports = async (client, torn, config) => {
value: `Nobody can sign up for ${difficulty.name} crimes!` value: `Nobody can sign up for ${difficulty.name} crimes!`
}) })
} else { } else {
embed.addFields({ embed.addFields({
name: `Difficulty ${difficulty.name}`, name: `Difficulty ${difficulty.name}`,
value: `There are ${difficulty.count} ${difficulty.name} crimes!` value: `There are ${difficulty.count} ${difficulty.name} crimes!`
}) })
@@ -76,14 +76,14 @@ module.exports = async (client, torn, config) => {
); );
channel.send({ embeds: [embed], components: [row] }); channel.send({ embeds: [embed], components: [row] });
state.ocAlertLast = now.toISOString(); state.ocAlertLast = now.toISOString();
fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => {if (err) {console.error(err)}}); fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => { if (err) { console.error(err) } });
} else { console.debug(`unavailableOC: Would send alert, but one was sent recently`); } } else { console.debug(`unavailableOC: Would send alert, but one was sent recently`); }
} else { } else {
console.debug(`unavailableOC: All crimes available, not sending alert`); console.debug(`unavailableOC: All crimes available, not sending alert`);
const now = new Date(); const now = new Date();
const twentyFourHoursAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000); const twentyFourHoursAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
state.ocAlertLast = twentyFourHoursAgo.toISOString(); state.ocAlertLast = twentyFourHoursAgo.toISOString();
fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => {if (err) {console.error(err)}}); fs.writeFile('./state.json', JSON.stringify(state, null, 4), err => { if (err) { console.error(err) } });
} }
}); });