configure combat log timer/refactor boolean configuration
This commit is contained in:
4 files changed
+30
-15
No files matched your search
@@ -148,18 +148,6 @@ module.exports = {
|
||||
description: "Enable/Disable periodic server checks and restart if stopped.",
|
||||
value: "auto-restart",
|
||||
type: CommandOptions.SubCommand,
|
||||
}, {
|
||||
name: "combat-log-timer",
|
||||
description: "Set the number of minutes to elapse for a player to not combat log. (Set to 0 to disbable combat logging detection)",
|
||||
value: "combat-log-timer",
|
||||
type: CommandOptions.SubCommand,
|
||||
options: [{
|
||||
name: "minutes",
|
||||
description: "Minutes to qualify combat log",
|
||||
value: 5,
|
||||
type: CommandOptions.Integer, // Integer
|
||||
|
||||
}]
|
||||
}],
|
||||
SlashCommand: {
|
||||
/**
|
||||
|
||||
+24
-1
@@ -317,6 +317,18 @@ module.exports = {
|
||||
type: CommandOptions.Boolean,
|
||||
required: true,
|
||||
}]
|
||||
}, {
|
||||
name: "combat-log-timer",
|
||||
description: "Set the number of minutes to elapse for a player to not combat log. (Set to 0 to disbable combat logging detection)",
|
||||
value: "combat-log-timer",
|
||||
type: CommandOptions.SubCommand,
|
||||
options: [{
|
||||
name: "minutes",
|
||||
description: "Minutes to qualify combat log",
|
||||
value: 5,
|
||||
type: CommandOptions.Integer,
|
||||
min_value: 0,
|
||||
}]
|
||||
}
|
||||
],
|
||||
SlashCommand: {
|
||||
@@ -522,7 +534,7 @@ module.exports = {
|
||||
return interaction.send({ embeds: [successSetKillfeedChannelEmbed] });
|
||||
|
||||
case 'show_killfeed_coords':
|
||||
const showKillfeedCoordsConfiguration = args[0].options[0].value;
|
||||
const showKillfeedCoordsConfiguration = args[0].options[0].value ? 1 : 0;
|
||||
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedCoords": showKillfeedCoordsConfiguration}}, (err, res) => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -715,6 +727,17 @@ module.exports = {
|
||||
|
||||
return interaction.send({ embeds: [successEMPPriceEmbed] });
|
||||
|
||||
case 'combat-log-timer':
|
||||
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.combatLogTimer":args[0].options[0].value}}, (err, res) => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
let successCobatLogTimerEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Green)
|
||||
.setDescription(`Successfully set combat log timer to **${args[0].options[0].value.toFixed(0)} minutes.**`);
|
||||
|
||||
return interaction.send({ embeds: [successCobatLogTimerEmbed] });
|
||||
|
||||
default:
|
||||
return client.sendInternalError(interaction, 'There was an error parsing the config command');
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ class DayzRBot extends Client {
|
||||
if (lines[i].includes('| ####')) continue;
|
||||
if (lines[i].includes("(id=Unknown") || lines[i].includes("Player \"Unknown Entity\"")) continue;
|
||||
if ((i - 1) >= 0 && lines[i] == lines[i - 1]) continue; // continue if this line is a duplicate of the last line
|
||||
if (lines[i].includes('connected') || lines[i].includes('pos=<') || lines[i].includes('hit by Player')) s = await HandlePlayerLogs(this, guildId, s, lines[i]);
|
||||
if (lines[i].includes('connected') || lines[i].includes('pos=<')) s = await HandlePlayerLogs(this, guildId, s, lines[i], guild.combatLogTimer);
|
||||
if (lines[i].includes('killed by with') || lines[i].includes('killed by LandMineTrap')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles explosive deaths
|
||||
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by') && lines[i].includes('TransportHit')) s = await HandleKillfeed(this, guildId, s, lines[i]) // Handles vehicle deaths
|
||||
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player') && lines[i].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles regular deaths
|
||||
@@ -411,6 +411,7 @@ class DayzRBot extends Client {
|
||||
empPrice: 500000,
|
||||
memberRole: "",
|
||||
adminRole: "",
|
||||
combatLogTimer: 5, // minutes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,6 +485,7 @@ class DayzRBot extends Client {
|
||||
uavPrice: guild.server.uavPrice,
|
||||
memberRole: guild.server.memberRole,
|
||||
adminRole: guild.server.adminRole,
|
||||
combatLogTimer: guild.server.combatLogTimer,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -9,7 +9,7 @@ let lastSendMessage;
|
||||
|
||||
module.exports = {
|
||||
|
||||
HandlePlayerLogs: async (client, guildId, stats, line) => {
|
||||
HandlePlayerLogs: async (client, guildId, stats, line, combatLogTimer = 5) => {
|
||||
|
||||
const connectTemplate = /(.*) \| Player \"(.*)\" is connected \(id=(.*)\)/g;
|
||||
const disconnectTemplate = /(.*) \| Player \"(.*)\"\(id=(.*)\) has been disconnected/g;
|
||||
@@ -86,6 +86,7 @@ module.exports = {
|
||||
lastConnectionDate: playerStat.lastConnectionDate,
|
||||
});
|
||||
|
||||
if (combatLogTimer != 0) {
|
||||
DetectCombatLog(client, guildId, {
|
||||
time: info.time,
|
||||
player: info.player,
|
||||
@@ -95,6 +96,7 @@ module.exports = {
|
||||
lastDeathDate: playerStat.lastDeathDate,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (line.includes('pos=<') && !line.includes('hit by')) {
|
||||
const data = [...line.matchAll(positionTemplate)][0];
|
||||
|
||||
Reference in new issue
Block a user