fix/issue #6
This commit is contained in:
4 files changed
+53
-19
No files matched your search
@@ -31,12 +31,12 @@ module.exports = {
|
||||
|
||||
let newDt = await client.getDateEST(data.time);
|
||||
|
||||
let diff = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000 / 60); // diff minutes
|
||||
let 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 and death was before logout event
|
||||
if (data.lastDamageDate <= data.lastDeathDate && data.lastDeathDate < newDt) return;
|
||||
if (diff > 5) return;
|
||||
// or if death after last combat
|
||||
if (data.lastDamageDate <= data.lastDeathDate) return;
|
||||
if (diffSeconds > (5 * 60)) return;
|
||||
|
||||
let guild = await client.GetGuild(guildId);
|
||||
if (!client.exists(guild.connectionLogsChannel)) return;
|
||||
|
||||
+10
-10
@@ -20,7 +20,6 @@ module.exports = {
|
||||
time: data[1],
|
||||
player: data[2],
|
||||
playerID: data[3],
|
||||
connected: true,
|
||||
};
|
||||
|
||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return stats;
|
||||
@@ -32,6 +31,7 @@ module.exports = {
|
||||
let newDt = await client.getDateEST(info.time);
|
||||
|
||||
playerStat.lastConnectionDate = newDt;
|
||||
playerStat.connected = true;
|
||||
|
||||
if (playerStatIndex == -1) stats.push(playerStat);
|
||||
else stats[playerStatIndex] = playerStat;
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
SendConnectionLogs(client, guildId, {
|
||||
time: info.time,
|
||||
player: info.player,
|
||||
connected: info.connected,
|
||||
connected: true,
|
||||
lastConnectionDate: null,
|
||||
});
|
||||
}
|
||||
@@ -52,7 +52,6 @@ module.exports = {
|
||||
time: data[1],
|
||||
player: data[2],
|
||||
playerID: data[3],
|
||||
connected: false
|
||||
}
|
||||
|
||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return stats;
|
||||
@@ -62,14 +61,15 @@ module.exports = {
|
||||
if (playerStat == undefined) playerStat = client.getDefaultPlayerStats(info.player, info.playerID);
|
||||
|
||||
let newDt = await client.getDateEST(info.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
let oldUnixTime = Math.floor(playerStat.lastConnectionDate.getTime()/1000);
|
||||
let seconds = unixTime - oldUnixTime;
|
||||
let unixTime = Math.round(newDt.getTime()/1000); // Seconds
|
||||
let oldUnixTime = Math.round(playerStat.lastConnectionDate.getTime()/1000); // Seconds
|
||||
let sessionTimeSeconds = unixTime - oldUnixTime;
|
||||
if (!client.exists(playerStat.longestSessionTime)) playerStat.longestSessionTime = 0;
|
||||
|
||||
playerStat.totalSessionTime = playerStat.totalSessionTime + seconds;
|
||||
playerStat.lastSessionTime = seconds;
|
||||
playerStat.longestSessionTime = seconds > playerStat.longestSessionTime ? seconds : playerStat.longestSessionTime;
|
||||
playerStat.totalSessionTime = playerStat.totalSessionTime + sessionTimeSeconds;
|
||||
playerStat.lastSessionTime = sessionTimeSeconds;
|
||||
playerStat.longestSessionTime = sessionTimeSeconds > playerStat.longestSessionTime ? sessionTimeSeconds : playerStat.longestSessionTime;
|
||||
playerStat.connected = false;
|
||||
|
||||
if (playerStatIndex == -1) stats.push(playerStat);
|
||||
else stats[playerStatIndex] = playerStat;
|
||||
@@ -77,7 +77,7 @@ module.exports = {
|
||||
SendConnectionLogs(client, guildId, {
|
||||
time: info.time,
|
||||
player: info.player,
|
||||
connected: info.connected,
|
||||
connected: false,
|
||||
lastConnectionDate: playerStat.lastConnectionDate,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user