fix/convert killfeed to webhooks
This commit is contained in:
2 files changed
+19
-5
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "13.3.18",
|
"version": "13.3.19",
|
||||||
"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": {
|
||||||
|
|||||||
+18
-4
@@ -5,6 +5,7 @@ const { nearest } = require('../database/destinations');
|
|||||||
const { getDefaultPlayer, UpdatePlayer } = require('../database/player');
|
const { getDefaultPlayer, UpdatePlayer } = require('../database/player');
|
||||||
const { calculateNewCombatRating } = require('./CombatRatingHandler');
|
const { calculateNewCombatRating } = require('./CombatRatingHandler');
|
||||||
const { weapons, weaponClassOf } = require('../database/weapons');
|
const { weapons, weaponClassOf } = require('../database/weapons');
|
||||||
|
const { GetWebhook, WebhookSend } = require("../util/WebhookHandler");
|
||||||
|
|
||||||
const Templates = {
|
const Templates = {
|
||||||
Killed: 1,
|
Killed: 1,
|
||||||
@@ -80,6 +81,7 @@ module.exports = {
|
|||||||
|
|
||||||
HandleKillfeed: async (NitradoServerID, client, guild, line) => {
|
HandleKillfeed: async (NitradoServerID, client, guild, line) => {
|
||||||
|
|
||||||
|
const NAME = "DayZ.R Killfeed";
|
||||||
const channel = client.GetChannel(guild.killfeedChannel);
|
const channel = client.GetChannel(guild.killfeedChannel);
|
||||||
|
|
||||||
const killedBy = line.includes('hit by Player') && line.includes('(DEAD)') && line.includes('meters') ? Templates.HitByAndDead :
|
const killedBy = line.includes('hit by Player') && line.includes('(DEAD)') && line.includes('meters') ? Templates.HitByAndDead :
|
||||||
@@ -131,6 +133,7 @@ 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.lastDeathDate = newDt;
|
victimStat.lastDeathDate = newDt;
|
||||||
@@ -144,9 +147,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}`);
|
||||||
|
|
||||||
if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
|
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);
|
await UpdatePlayer(client, victimStat);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KillInAlarm(client, guild.serverID, info); // check if kill happened in a no kill zone
|
KillInAlarm(client, guild.serverID, info); // check if kill happened in a no kill zone
|
||||||
@@ -263,8 +270,15 @@ module.exports = {
|
|||||||
killEvent.setThumbnail(weapons[weaponClass][weapon])
|
killEvent.setThumbnail(weapons[weaponClass][weapon])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
|
if (!channel) return;
|
||||||
if (client.exists(receivedBounty) && client.exists(channel)) await channel.send({ content: `<@${killerStat.discordID}>`, embeds: [receivedBounty] });
|
|
||||||
|
const webhook = await GetWebhook(this, NAME, guild.killfeedChannel);
|
||||||
|
|
||||||
|
WebhookSend(client, webhook, { embeds: [killEvent] });
|
||||||
|
if (client.exists(receivedBounty) && client.exists(channel)) WebhookSend(client, webhook, { content: `<@${killerStat.discordID}>`, embeds: [receivedBounty] });
|
||||||
|
|
||||||
|
// if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
|
||||||
|
// if (client.exists(receivedBounty) && client.exists(channel)) await channel.send({ content: `<@${killerStat.discordID}>`, embeds: [receivedBounty] });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user