6.13.0 track time played

This commit is contained in:
SowinskiBraeden committed 2023-06-08 13:14:38 -07:00
1 parent 49d6bc2047
commit bfde05aeaa
4 files changed
+25 -5

No files matched your search

+14
View File
@@ -58,7 +58,21 @@ module.exports = {
if (!client.exists(info.player) || !client.exists(info.playerID)) return stats;
let playerStat = stats.find(stat => stat.playerID == info.playerID)
let playerStatIndex = stats.indexOf(playerStat);
if (playerStat == undefined) playerStat = client.getDefaultPlayerStats(info.player, info.playerID);
if (!client.exists(playerStat.totalSessionTime)) playerStat.totalSessionTime = 0;
let newDt = await client.getDateEST(info.time);
let unixTime = Math.floor(newDt.getTime()/1000);
let oldUnixTime = Math.floor(data.lastConnectionDate.getTime()/1000);
let seconds = unixTime - oldUnixTime;
let sessionTime = client.secondsToDhms(seconds);
playerStat.totalSessionTime = playerStat.totalSessionTime + seconds;
playerStat.lastSessionTime = sessionTime;
if (playerStatIndex == -1) stats.push(playerStat);
else stats[playerStatIndex] = playerStat;
SendConnectionLogs(client, guildId, {
time: info.time,