refactoring

This commit is contained in:
SowinskiBraeden committed 2023-09-10 19:01:03 -07:00
1 parent 924f64cf00
commit b1e2ecfb2c
4 files changed
+8 -11

No files matched your search

+3 -4
View File
@@ -28,14 +28,13 @@ module.exports = {
DetectCombatLog: async (client, guildId, data) => {
if (data.lastDamageDate == null) return;
let newDt = await client.getDateEST(data.time);
let diffSeconds = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000);
const newDt = await client.getDateEST(data.time);
const diffSeconds = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000);
// If diff is greater than 5 minutes, not a combat log
// or if death after last combat
if (diffSeconds > (data.combatLogTimer * 60)) return;
if (data.lastDamageDate <= data.lastDeathDate) return;
if (diffSeconds > 5 * 60) return;
let guild = await client.GetGuild(guildId);
if (!client.exists(guild.connectionLogsChannel)) return;
+2 -2
View File
@@ -72,8 +72,8 @@ module.exports = {
else if (killedBy == Templates.Explosion) info.causeOfDeath = data[5];
else return stats; // Unknown template;
let newDt = await client.getDateEST(info.time);
let unixTime = Math.floor(newDt.getTime()/1000);
const newDt = await client.getDateEST(info.time);
const unixTime = Math.floor(newDt.getTime()/1000);
const showCoords = client.exists(guild.showKillfeedCoords) ? guild.showKillfeedCoords : false; // default to false if no record of configuration.
+2 -3
View File
@@ -109,6 +109,7 @@ module.exports = {
lastDamageDate: playerStat.lastDamageDate,
lastHitBy: playerStat.lastHitBy,
lastDeathDate: playerStat.lastDeathDate,
combatLogTimer: combatLogTimer,
});
}
}
@@ -169,9 +170,7 @@ module.exports = {
let playerStatIndex = stats.indexOf(playerStat);
if (playerStat === undefined) playerStat = client.getDefaultPlayerStats(info.player, info.playerID);
const newDt = await client.getDateEST(info.time);
playerStat.lastDamageDate = newDt;
playerStat.lastDamageDate = await client.getDateEST(info.time);
playerStat.lastHitBy = info.attacker;
if (playerStatIndex === -1) stats.push(playerStat);