fix unavailableOC
This commit is contained in:
@@ -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
|
||||||
@@ -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) } });
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user