fix/update victim stats after explosive death

This commit is contained in:
SowinskiBraeden committed 2024-11-17 12:50:09 -08:00
1 parent d1550ff7b5
commit 72922dc3a3
2 files changed
+10 -5

No files matched your search

+1 -1
View File
@@ -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": {
+9 -4
View File
@@ -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** - <t:${unixTime}>\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;
}