diff --git a/package.json b/package.json index 18c4f3d..60b7700 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "9.0.1", + "version": "9.1.0", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": { diff --git a/structures/DayzRBot.js b/structures/DayzRBot.js index 8fadbf5..30a6f6e 100644 --- a/structures/DayzRBot.js +++ b/structures/DayzRBot.js @@ -142,7 +142,7 @@ class DayzRBot extends Client { if (lines[i].includes("(id=Unknown") || lines[i].includes("Player \"Unknown Entity\"")) continue; if ((i - 1) >= 0 && lines[i] == lines[i-1]) continue; // continue if this line is a duplicate of the last line if (lines[i].includes('connected') || lines[i].includes('pos=<') || lines[1].includes('hit by Player')) s = await HandlePlayerLogs(this, guildId, s, lines[i]); - if (lines[i].includes('killed by with')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles explosive deaths + if (lines[i].includes('killed by with') || lines[i].includes('killed by LandMineTrap')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles explosive deaths if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player') && lines[i].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); if (lines[i].includes('killed by Player') && !lines[i - 1].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); } diff --git a/util/KillfeedHandler.js b/util/KillfeedHandler.js index c62ac37..92b8668 100644 --- a/util/KillfeedHandler.js +++ b/util/KillfeedHandler.js @@ -13,14 +13,17 @@ module.exports = { let template = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g; let templateDEAD = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g; let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by with (.*)/g; - + let landMineTemplate = /(.8) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by LandMineTrap/g; + let killedBy = line.includes('hit by Player') && line.includes('(DEAD)') ? 1 : line.includes('hit by Player') ? 2 : - line.includes('killed by Player') ? 3 : 4; + line.includes('killed by Player') ? 3 : + line.includes('killed by LandMineTrap') ? 4 : 5; let data = killedBy == 1 ? [...line.matchAll(templateDEAD)][0] : killedBy == 2 ? [...line.matchAll(template)][0] : killedBy == 3 ? [...line.matchAll(templateKilled)][0] : + killedBy == 4 ? [...line.matchAll(landMineTemplate)][0] : [...line.matchAll(explosionTemplate)][0] if (!data) return stats; @@ -49,15 +52,17 @@ module.exports = { info.killerPOS = data[7].split(', ').map(v => parseFloat(v)); info.weapon = data[8]; info.distance = data[9]; - } else info.causeOfDeath = data[5]; + } else if (killedBy == 5) info.causeOfDeath = data[5]; // use 'else if' because it will cause error if killedBy == 4 (LandMineTrap) let newDt = await client.getDateEST(info.time); let unixTime = Math.floor(newDt.getTime()/1000); - if (killedBy == 4) { + if (killedBy == 4 || killedBy == 5) { + let cod = killedBy == 4 ? `Land Mine Trap` : info.causeOfDeath; + const killEvent = new EmbedBuilder() .setColor(client.config.Colors.Default) - .setDescription(`**Death Event** - \n**${info.victim}** killed by a **${info.causeOfDeath}.\nLocation [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**`); + .setDescription(`**Death Event** - \n**${info.victim}** killed by a **${cod}.\nLocation [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**`); if (client.exists(channel)) await channel.send({ embeds: [killEvent] }); return stats;