update/queue alarm ping
This commit is contained in:
3 files changed
+27
-14
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dayzr-bot",
|
||||
"version": "10.0.12",
|
||||
"version": "10.1.0",
|
||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||
"main": "index.js",
|
||||
"nodemonConfig": {
|
||||
|
||||
@@ -41,6 +41,7 @@ class DayzRBot extends Client {
|
||||
this.arInterval = arInterval;
|
||||
this.arIntervalId; // Interval for auto-restart functions
|
||||
this.playerSessions = new Map();
|
||||
this.alarmPingQueue = {};
|
||||
this.autoRestartInit();
|
||||
this.LoadCommandsAndInteractionHandlers();
|
||||
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
|
||||
}
|
||||
|
||||
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;
|
||||
let previouslyConnected = s.filter(p => p.connected); // All players with connection log captured above and no disconnect log
|
||||
let lastDetectedTime;
|
||||
|
||||
+17
-13
@@ -57,29 +57,33 @@ module.exports = {
|
||||
let distance = Math.sqrt(Math.pow(diff[0], 2) + Math.pow(diff[1], 2)).toFixed(2)
|
||||
|
||||
if (distance < alarm.radius) {
|
||||
const channel = client.GetChannel(alarm.channel);
|
||||
|
||||
let newDt = await client.getDateEST(data.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
|
||||
if (!client.alarmPingQueue[alarm.channel]) client.alarmPingQueue[alarm.channel] = {};
|
||||
if (!client.alarmPingQueue[alarm.channel][alarm.role]) client.alarmPingQueue[alarm.channel][alarm.role] = [];
|
||||
|
||||
if (alarm.rules.includes['ban_on_entry']) {
|
||||
|
||||
let alarmEmbed = new EmbedBuilder()
|
||||
.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.__`)
|
||||
.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] });
|
||||
client.alarmPingQueue[alarm.channel][alarm.role].push(
|
||||
new EmbedBuilder()
|
||||
.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.__`)
|
||||
.addFields({ name: '**Location**', value: `**[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`, inline: false })
|
||||
);
|
||||
|
||||
BanPlayer(client, data.player);
|
||||
return;
|
||||
}
|
||||
|
||||
let alarmEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
.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 })
|
||||
client.alarmPingQueue[alarm.channel][alarm.role].push(
|
||||
new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
.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 })
|
||||
);
|
||||
|
||||
return await channel.send({ content: `<@&${alarm.role}>`, embeds: [alarmEmbed] });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user