From 72922dc3a32123f81bdf89ec18a4864250f62d86 Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Sun, 17 Nov 2024 12:50:09 -0800 Subject: [PATCH] fix/update victim stats after explosive death --- package.json | 2 +- util/KillfeedHandler.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3ff9358..cc94097 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "13.3.20", + "version": "13.3.21", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": { diff --git a/util/KillfeedHandler.js b/util/KillfeedHandler.js index 3528198..7e6c6c4 100644 --- a/util/KillfeedHandler.js +++ b/util/KillfeedHandler.js @@ -133,11 +133,15 @@ module.exports = { if ([Templates.LandMine, Templates.Explosion, Templates.Vehicle].includes(killedBy)) if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) { - if (!channel) return; let victimStat = await client.dbo.collection("players").findOne({"playerID": info.victimID}); if (!client.exists(victimStat)) victimStat = getDefaultPlayer(info.victim, info.victimID, NitradoServerID); + victimStat.deaths++; + victimStat.deathStreak++; + victimStat.worstDeathStreak = victimStat.deathStreak > victimStat.worstDeathStreak ? victimStat.deathStreak : victimStat.worstDeathStreak; + victimStat.KDR = victimStat.kills / (victimStat.deaths == 0 ? 1 : victimStat.deaths); // prevent division by 0 + victimStat.killStreak = 0; victimStat.lastDeathDate = newDt; - + const cod = killedBy == Templates.LandMine ? `Land Mine Trap` : killedBy == Templates.Vehicle ? Vehicles[info.causeOfDeath] : info.causeOfDeath; const coord = showCoords ? `\n***Location [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})***\n${destination}` : ''; @@ -147,12 +151,13 @@ module.exports = { .setColor(client.config.Colors.Default) .setDescription(`**Death Event** - \n**${info.victim}** ${killMessage} a **${cod}.**${coord}`); + await UpdatePlayer(client, victimStat); + + if (!channel) return; const webhook = await GetWebhook(this, NAME, guild.killfeedChannel); - WebhookSend(client, webhook, { embeds: [killEvent]}); // if (client.exists(channel)) await channel.send({ embeds: [killEvent] }); - await UpdatePlayer(client, victimStat); return; }