fix/update victim stats after explosive death
This commit is contained in:
2 files changed
+10
-5
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "13.3.20",
|
"version": "13.3.21",
|
||||||
"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": {
|
||||||
|
|||||||
@@ -133,11 +133,15 @@ module.exports = {
|
|||||||
|
|
||||||
if ([Templates.LandMine, Templates.Explosion, Templates.Vehicle].includes(killedBy))
|
if ([Templates.LandMine, Templates.Explosion, Templates.Vehicle].includes(killedBy))
|
||||||
if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) {
|
if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) {
|
||||||
if (!channel) return;
|
|
||||||
let victimStat = await client.dbo.collection("players").findOne({"playerID": info.victimID});
|
let victimStat = await client.dbo.collection("players").findOne({"playerID": info.victimID});
|
||||||
if (!client.exists(victimStat)) victimStat = getDefaultPlayer(info.victim, info.victimID, NitradoServerID);
|
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;
|
victimStat.lastDeathDate = newDt;
|
||||||
|
|
||||||
const cod = killedBy == Templates.LandMine ? `Land Mine Trap` :
|
const cod = killedBy == Templates.LandMine ? `Land Mine Trap` :
|
||||||
killedBy == Templates.Vehicle ? Vehicles[info.causeOfDeath] : info.causeOfDeath;
|
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}` : '';
|
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)
|
.setColor(client.config.Colors.Default)
|
||||||
.setDescription(`**Death Event** - <t:${unixTime}>\n**${info.victim}** ${killMessage} a **${cod}.**${coord}`);
|
.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);
|
const webhook = await GetWebhook(this, NAME, guild.killfeedChannel);
|
||||||
|
|
||||||
WebhookSend(client, webhook, { embeds: [killEvent]});
|
WebhookSend(client, webhook, { embeds: [killEvent]});
|
||||||
|
|
||||||
// if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
|
// if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
|
||||||
await UpdatePlayer(client, victimStat);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user