6.13.0 track time played
This commit is contained in:
4 files changed
+25
-5
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user