update/queue alarm ping

This commit is contained in:
SowinskiBraeden committed 2023-09-24 17:59:53 -07:00
1 parent b5dca5ad07
commit 961522930f
3 files changed
+21 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dayzr-bot", "name": "dayzr-bot",
"version": "10.0.12", "version": "10.1.0",
"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": {
+9
View File
@@ -41,6 +41,7 @@ class DayzRBot extends Client {
this.arInterval = arInterval; this.arInterval = arInterval;
this.arIntervalId; // Interval for auto-restart functions this.arIntervalId; // Interval for auto-restart functions
this.playerSessions = new Map(); this.playerSessions = new Map();
this.alarmPingQueue = {};
this.autoRestartInit(); this.autoRestartInit();
this.LoadCommandsAndInteractionHandlers(); this.LoadCommandsAndInteractionHandlers();
this.LoadEvents(); this.LoadEvents();
@@ -155,6 +156,14 @@ class DayzRBot extends Client {
if (lines[i].includes('killed by Player') && !lines[i - 1].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles deaths missing hit by log if (lines[i].includes('killed by Player') && !lines[i - 1].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles deaths missing hit by log
} }
for (const [channel_id, role] of Object.entries(client.alarmPingQueue)) {
const channel = client.GetChannel(channel_id);
channel.send({ content: `<@&${role}>`, embeds: client.alarmPingQueue[channel_id][role] });
}
client.alarmPingQueue = {};
const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g; const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
let previouslyConnected = s.filter(p => p.connected); // All players with connection log captured above and no disconnect log let previouslyConnected = s.filter(p => p.connected); // All players with connection log captured above and no disconnect log
let lastDetectedTime; let lastDetectedTime;
+11 -7
View File
@@ -57,29 +57,33 @@ module.exports = {
let distance = Math.sqrt(Math.pow(diff[0], 2) + Math.pow(diff[1], 2)).toFixed(2) let distance = Math.sqrt(Math.pow(diff[0], 2) + Math.pow(diff[1], 2)).toFixed(2)
if (distance < alarm.radius) { if (distance < alarm.radius) {
const channel = client.GetChannel(alarm.channel);
let newDt = await client.getDateEST(data.time); let newDt = await client.getDateEST(data.time);
let unixTime = Math.floor(newDt.getTime()/1000); let unixTime = Math.floor(newDt.getTime()/1000);
if (alarm.rules.includes['ban_on_entry']) { if (!client.alarmPingQueue[alarm.channel]) client.alarmPingQueue[alarm.channel] = {};
if (!client.alarmPingQueue[alarm.channel][alarm.role]) client.alarmPingQueue[alarm.channel][alarm.role] = [];
let alarmEmbed = new EmbedBuilder() if (alarm.rules.includes['ban_on_entry']) {
client.alarmPingQueue[alarm.channel][alarm.role].push(
new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned.__`) .setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned.__`)
.addFields({ name: '**Location**', value: `**[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`, inline: false }) .addFields({ name: '**Location**', value: `**[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`, inline: false })
);
channel.send({ content: `<@&${alarm.role}>`, embeds: [alarmEmbed] });
BanPlayer(client, data.player); BanPlayer(client, data.player);
return;
} }
let alarmEmbed = new EmbedBuilder() client.alarmPingQueue[alarm.channel][alarm.role].push(
new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}**`) .setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}**`)
.addFields({ name: '**Location**', value: `**[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`, inline: false }) .addFields({ name: '**Location**', value: `**[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`, inline: false })
);
return await channel.send({ content: `<@&${alarm.role}>`, embeds: [alarmEmbed] }); return;
} }
} }