enhance/combat log detection

This commit is contained in:
SowinskiBraeden committed 2023-10-07 09:24:53 -07:00
1 parent a5a760e29f
commit c7b417ec43
3 files changed
+10 -4

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ require('dotenv').config();
module.exports = { module.exports = {
Dev: process.env.Dev || "DEV.", Dev: process.env.Dev || "DEV.",
Version: package.version, // (major).(feature).(revision/bug/refactoring) Version: package.version, // (major).(feature).(patch)
Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot
ServerID: "1050215624053374976", ServerID: "1050215624053374976",
GuildID: process.env.GuildID || "", GuildID: process.env.GuildID || "",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dayzr-bot", "name": "dayzr-bot",
"version": "10.1.2", "version": "10.1.3",
"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": {
+8 -2
View File
@@ -28,6 +28,9 @@ module.exports = {
DetectCombatLog: async (client, guildId, data) => { DetectCombatLog: async (client, guildId, data) => {
if (!client.exists(data.lastDamageDate)) return; if (!client.exists(data.lastDamageDate)) return;
let guild = await client.GetGuild(guildId);
if (!client.exists(guild.connectionLogsChannel)) return;
const newDt = await client.getDateEST(data.time); const newDt = await client.getDateEST(data.time);
const diffSeconds = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000); const diffSeconds = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000);
@@ -36,8 +39,11 @@ module.exports = {
if (diffSeconds > (data.combatLogTimer * 60)) return; if (diffSeconds > (data.combatLogTimer * 60)) return;
if (data.lastDamageDate <= data.lastDeathDate) return; if (data.lastDamageDate <= data.lastDeathDate) return;
let guild = await client.GetGuild(guildId); // If lastHitBy (attacker) died to this player or another,
if (!client.exists(guild.connectionLogsChannel)) return; // then it does not count as combat logging, (the combat ended)
let attacker = guild.playerstats.find(stat => stat.gamertag = data.lastHitBy);
if (attacker.lastDeathDate > data.lastDamageDate) return;
const channel = client.GetChannel(guild.connectionLogsChannel); const channel = client.GetChannel(guild.connectionLogsChannel);
if (!channel) return; if (!channel) return;