Merge pull request #20 from IrPgFKS0/co-work
This commit is contained in:
5 files changed
+13
-12
No files matched your search
+1
-1
@@ -319,7 +319,7 @@ module.exports = {
|
|||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
name: "combat-log-timer",
|
name: "combat-log-timer",
|
||||||
description: "Set the number of minutes to elapse for a player to not combat log. (Set to 0 to disbable combat logging detection)",
|
description: "Adjust log timeout for combat prevention. (0 disables combat log)",
|
||||||
value: "combat-log-timer",
|
value: "combat-log-timer",
|
||||||
type: CommandOptions.SubCommand,
|
type: CommandOptions.SubCommand,
|
||||||
options: [{
|
options: [{
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ module.exports = {
|
|||||||
{ name: 'Latency', value: `${end - start}ms`, inline: true },
|
{ name: 'Latency', value: `${end - start}ms`, inline: true },
|
||||||
{ name: 'Uptime', value: `${client.secondsToDhms(process.uptime().toFixed(2))}`, inline: true },
|
{ name: 'Uptime', value: `${client.secondsToDhms(process.uptime().toFixed(2))}`, inline: true },
|
||||||
{ name: 'Bot Version', value: `${client.config.Dev} v${client.config.Version}`, inline: true },
|
{ name: 'Bot Version', value: `${client.config.Dev} v${client.config.Version}`, inline: true },
|
||||||
{ name: 'Discord Version', value: 'Discord.js ^14.8.0', inline: true },
|
{ name: 'Discord Version', value: 'Discord.js v14.8.0', inline: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
return interaction.send({ embeds: [stats] })
|
return interaction.send({ embeds: [stats] })
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "9.9.6",
|
"version": "9.9.7",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const { RegisterGlobalCommands, RegisterGuildCommands } = require("../util/RegisterSlashCommands");
|
const { RegisterGlobalCommands, RegisterGuildCommands } = require("../util/RegisterSlashCommands");
|
||||||
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
|
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
|
||||||
|
const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes;
|
||||||
const MongoClient = require('mongodb').MongoClient;
|
const MongoClient = require('mongodb').MongoClient;
|
||||||
const { REST } = require('@discordjs/rest');
|
const { REST } = require('@discordjs/rest');
|
||||||
const Logger = require("../util/Logger");
|
const Logger = require("../util/Logger");
|
||||||
@@ -155,7 +156,6 @@ class DayzRBot extends Client {
|
|||||||
const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
|
const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
|
||||||
const playerSessions = new Map();
|
const playerSessions = new Map();
|
||||||
let previouslyConnected = s.filter(p => p.connected); // All players with connection log captured above and no disconnect log
|
let previouslyConnected = s.filter(p => p.connected); // All players with connection log captured above and no disconnect log
|
||||||
let detectedAsConnected = [];
|
|
||||||
let lastDetectedTime;
|
let lastDetectedTime;
|
||||||
|
|
||||||
for (let i = lines.length - 1; i > 0; i--) {
|
for (let i = lines.length - 1; i > 0; i--) {
|
||||||
@@ -173,38 +173,37 @@ class DayzRBot extends Client {
|
|||||||
playerID: data[3],
|
playerID: data[3],
|
||||||
};
|
};
|
||||||
|
|
||||||
lastDetectedTime = info.time;
|
lastDetectedTime = await this.getDateEST(info.time);
|
||||||
|
|
||||||
if (!this.exists(info.player) || !this.exists(info.playerID)) continue;
|
if (!this.exists(info.player) || !this.exists(info.playerID)) continue; // Skip this player if the player does not exist.
|
||||||
|
let playerStat = s.find(stat => stat.playerID == info.playerID);
|
||||||
|
if (!previouslyConnected.includes(playerStat) && this.exists(playerStat.lastDisconnectionDate) && playerStat.lastDisconnectionDate !== null && playerStat.lastDisconnectionDate.getTime() > lastDetectedTime.getTime()) continue; // Skip this player if the lastDisconnectionDate time is later than the player log entry.
|
||||||
|
|
||||||
// Check if the player session exists in the map.
|
// Check if the player session exists in the map.
|
||||||
if (playerSessions.has(info.playerID)) {
|
if (playerSessions.has(info.playerID)) {
|
||||||
// Player is already in a session, update the session's end time.
|
// Player is already in a session, update the session's end time.
|
||||||
const session = playerSessions.get(info.playerID);
|
const session = playerSessions.get(info.playerID);
|
||||||
session.endTime = await this.getDateEST(info.time); // Update end time.
|
session.endTime = lastDetectedTime; // Update end time.
|
||||||
} else {
|
} else {
|
||||||
// Player is not in a session, create a new session.
|
// Player is not in a session, create a new session.
|
||||||
const newSession = {
|
const newSession = {
|
||||||
startTime: await this.getDateEST(info.time),
|
startTime: lastDetectedTime,
|
||||||
endTime: null, // Initialize end time as null.
|
endTime: null, // Initialize end time as null.
|
||||||
};
|
};
|
||||||
playerSessions.set(info.playerID, newSession);
|
playerSessions.set(info.playerID, newSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
let playerStat = s.find(stat => stat.playerID == info.playerID);
|
|
||||||
let playerStatIndex = s.indexOf(playerStat);
|
let playerStatIndex = s.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
|
|
||||||
if (!previouslyConnected.includes(playerStat)) {
|
if (!previouslyConnected.includes(playerStat)) {
|
||||||
// Check if the player has been marked as connected before.
|
// Check if the player has been marked as connected before.
|
||||||
playerStat.connected = true;
|
playerStat.connected = true;
|
||||||
playerStat.lastConnectionDate = await this.getDateEST(info.time); // Update last connection date.
|
playerStat.lastConnectionDate = lastDetectedTime; // Update last connection date.
|
||||||
detectedAsConnected.push(playerStat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerStatIndex == -1) s.push(playerStat);
|
if (playerStatIndex == -1) s.push(playerStat);
|
||||||
else s[playerStatIndex] = playerStat;
|
else s[playerStatIndex] = playerStat;
|
||||||
detectedAsConnected.push(playerStat);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -433,6 +432,7 @@ class DayzRBot extends Client {
|
|||||||
time: null,
|
time: null,
|
||||||
lastTime: null,
|
lastTime: null,
|
||||||
lastConnectionDate: null,
|
lastConnectionDate: null,
|
||||||
|
lastDisconnectionDate: null,
|
||||||
lastDamageDate: null,
|
lastDamageDate: null,
|
||||||
lastDeathDate: null,
|
lastDeathDate: null,
|
||||||
lastHitBy: null,
|
lastHitBy: null,
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ module.exports = {
|
|||||||
playerStat.totalSessionTime = playerStat.totalSessionTime + sessionTimeSeconds;
|
playerStat.totalSessionTime = playerStat.totalSessionTime + sessionTimeSeconds;
|
||||||
playerStat.lastSessionTime = sessionTimeSeconds;
|
playerStat.lastSessionTime = sessionTimeSeconds;
|
||||||
playerStat.longestSessionTime = sessionTimeSeconds > playerStat.longestSessionTime ? sessionTimeSeconds : playerStat.longestSessionTime;
|
playerStat.longestSessionTime = sessionTimeSeconds > playerStat.longestSessionTime ? sessionTimeSeconds : playerStat.longestSessionTime;
|
||||||
|
playerStat.lastDisconnectionDate = newDt;
|
||||||
playerStat.connected = false;
|
playerStat.connected = false;
|
||||||
|
|
||||||
if (playerStatIndex === -1) stats.push(playerStat);
|
if (playerStatIndex === -1) stats.push(playerStat);
|
||||||
|
|||||||
Reference in new issue
Block a user