fix/update victim stats after explosive death
This commit is contained in:
2 files changed
+9
-4
No files matched your search
+1
-1
@@ -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": {
|
||||
|
||||
@@ -133,9 +133,13 @@ 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` :
|
||||
@@ -147,12 +151,13 @@ module.exports = {
|
||||
.setColor(client.config.Colors.Default)
|
||||
.setDescription(`**Death Event** - <t:${unixTime}>\n**${info.victim}** ${killMessage} a **${cod}.**${coord}`);
|
||||
|
||||
const webhook = await GetWebhook(this, NAME, guild.killfeedChannel);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user