alarm rules
This commit is contained in:
4 files changed
+66
-45
No files matched your search
+23
-24
@@ -130,31 +130,30 @@ module.exports = {
|
|||||||
description: "Enable an Zone Alarm",
|
description: "Enable an Zone Alarm",
|
||||||
value: "enable",
|
value: "enable",
|
||||||
type: 1,
|
type: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "set-rule",
|
||||||
|
description: "Add a Rule to an Alarm",
|
||||||
|
value: "set-rule",
|
||||||
|
type: 1,
|
||||||
|
options: [{
|
||||||
|
name: "rule",
|
||||||
|
description: "Rule to Add to an Alarm",
|
||||||
|
value: "rule",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
choices: [
|
||||||
|
{ name: 'Ban on Entry', value: 'ban_on_entry' },
|
||||||
|
{ name: 'Ban on Kill', value: 'ban_on_kill' }
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "remove-rule",
|
||||||
|
description: "Remove a Rule from an Alarm",
|
||||||
|
value: "remove-rule",
|
||||||
|
type: 1,
|
||||||
}
|
}
|
||||||
// {
|
|
||||||
// name: "set-rule",
|
|
||||||
// description: "Add a Rule to an Alarm",
|
|
||||||
// value: "set-rule",
|
|
||||||
// type: 1,
|
|
||||||
// options: [{
|
|
||||||
// name: "rule",
|
|
||||||
// description: "Rule to Add to an Alarm",
|
|
||||||
// value: "rule",
|
|
||||||
// type: 3,
|
|
||||||
// required: true,
|
|
||||||
// choices: [
|
|
||||||
// { name: 'Ban on Entry', value: 'ban_on_entry' },
|
|
||||||
// { name: 'Ban on Kill', value: 'ban_on_kill' },
|
|
||||||
// { name: 'Ban on IED Set', value: 'ban_on_ied_set' },
|
|
||||||
// ]
|
|
||||||
// }]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: "remove-rule",
|
|
||||||
// description: "Remove a Rule from an Alarm",
|
|
||||||
// value: "remove-rule",
|
|
||||||
// type: 1,
|
|
||||||
// }
|
|
||||||
],
|
],
|
||||||
SlashCommand: {
|
SlashCommand: {
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "6.0.4",
|
"version": "6.1.0",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
+40
-18
@@ -7,17 +7,6 @@ module.exports = {
|
|||||||
|
|
||||||
let guild = await client.GetGuild(guildId);
|
let guild = await client.GetGuild(guildId);
|
||||||
|
|
||||||
if (!client.exists(guild.alarms)) {
|
|
||||||
guild.alarms = [];
|
|
||||||
await client.dbo.collection("guilds").updateOne({ 'server.serverID': guildId }, {
|
|
||||||
$set: {
|
|
||||||
'server.alarms': [],
|
|
||||||
}
|
|
||||||
}, function (err, res) {
|
|
||||||
if (err) client.error(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < guild.alarms.length; i++) {
|
for (let i = 0; i < guild.alarms.length; i++) {
|
||||||
let alarm = guild.alarms[i];
|
let alarm = guild.alarms[i];
|
||||||
if (alarm.disabled) continue; // ignore if alarm is disabled due to emp
|
if (alarm.disabled) continue; // ignore if alarm is disabled due to emp
|
||||||
@@ -32,15 +21,18 @@ module.exports = {
|
|||||||
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 (alarm.rules.includes['ban_on_entry']) {
|
||||||
|
|
||||||
// let alarmEmbed = new EmbedBuilder()
|
let alarmEmbed = 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] });
|
||||||
|
|
||||||
|
HandlePlayerBan(client, data.player, true);
|
||||||
|
}
|
||||||
|
|
||||||
// channel.send({ content: `<@&${alarm.role}>`, embeds: [alarmEmbed] });
|
|
||||||
// } else {
|
|
||||||
let alarmEmbed = new EmbedBuilder()
|
let alarmEmbed = 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}**`)
|
||||||
@@ -50,5 +42,35 @@ module.exports = {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
KillInAlarm: async (client, guildId, data) => {
|
||||||
|
|
||||||
|
let guild = await client.GetGuild(guildId);
|
||||||
|
|
||||||
|
for (let i = 0; i < guild.alarms.length; i++) {
|
||||||
|
let alarm = guild.alarms[i];
|
||||||
|
if (alarm.disabled || !alarm.rules.includes('ban_on_kill')) continue; // ignore if alarm is disabled or not ban on kill;
|
||||||
|
if (alarm.ignoredPlayers.includes(data.killerID)) continue;
|
||||||
|
|
||||||
|
let diff = [Math.round(alarm.origin[0] - data.killerPOS[0]), Math.round(alarm.origin[1] - data.killerPOS[1])];
|
||||||
|
let distance = Math.sqrt(Math.pow(diff[0], 2) + Math.pow(diff[1], 2)).toFixed(2)
|
||||||
|
|
||||||
|
if (distance < alarm.radius) {
|
||||||
|
const channel = client.channels.cache.get(alarm.channel);
|
||||||
|
|
||||||
|
let newDt = await client.getDateEST(data.time);
|
||||||
|
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
|
let alarmEmbed = new EmbedBuilder()
|
||||||
|
.setColor(client.config.Colors.Default)
|
||||||
|
.setDescription(`**Zone Ping - <t:${unixTime}>**\n**${data.killer}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned for killing **${data.victim}**.__`)
|
||||||
|
.addFields({ name: '**Location**', value: `**[${data.killerPOS[0]}, ${data.killerPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.killerPOS[0]};${data.killerPOS[1]})**`, inline: false })
|
||||||
|
|
||||||
|
channel.send({ content: `<@&${alarm.role}>`, embeds: [alarmEmbed] });
|
||||||
|
|
||||||
|
HandlePlayerBan(client, data.player, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -32,8 +32,8 @@ module.exports = {
|
|||||||
|
|
||||||
let bans = res.data.gameserver.settings.general.bans;
|
let bans = res.data.gameserver.settings.general.bans;
|
||||||
if (ban) bans += `${gamertag}\r\n`;
|
if (ban) bans += `${gamertag}\r\n`;
|
||||||
if (!ban) bans = bans.replace(`${gamertag}\r\n`, '');
|
else if (!ban) bans = bans.replace(`${gamertag}\r\n`, '');
|
||||||
if (ban != true && ban != false) {
|
else {
|
||||||
client.error("Incorrect Ban Option: HandlePlayerBan")
|
client.error("Incorrect Ban Option: HandlePlayerBan")
|
||||||
throw "Incorrect Ban Option: HandlePlayerBan"
|
throw "Incorrect Ban Option: HandlePlayerBan"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user