refactoring
This commit is contained in:
4 files changed
+8
-11
No files matched your search
@@ -1,6 +1,5 @@
|
|||||||
const { RegisterGlobalCommands, RegisterGuildCommands } = require("../util/RegisterSlashCommands");
|
const { RegisterGlobalCommands, RegisterGuildCommands } = require("../util/RegisterSlashCommands");
|
||||||
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
|
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
|
||||||
const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes;
|
|
||||||
const MongoClient = require('mongodb').MongoClient;
|
const MongoClient = require('mongodb').MongoClient;
|
||||||
const { REST } = require('@discordjs/rest');
|
const { REST } = require('@discordjs/rest');
|
||||||
const Logger = require("../util/Logger");
|
const Logger = require("../util/Logger");
|
||||||
@@ -80,7 +79,7 @@ class DayzRBot extends Client {
|
|||||||
|
|
||||||
return await rest.post(Routes.interactionCallback(interaction.id, interaction.token), {
|
return await rest.post(Routes.interactionCallback(interaction.id, interaction.token), {
|
||||||
body: {
|
body: {
|
||||||
type: CommandOptions.Integer,
|
type: 4,
|
||||||
data: message,
|
data: message,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,14 +28,13 @@ module.exports = {
|
|||||||
DetectCombatLog: async (client, guildId, data) => {
|
DetectCombatLog: async (client, guildId, data) => {
|
||||||
if (data.lastDamageDate == null) return;
|
if (data.lastDamageDate == null) return;
|
||||||
|
|
||||||
let newDt = await client.getDateEST(data.time);
|
const newDt = await client.getDateEST(data.time);
|
||||||
|
const diffSeconds = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000);
|
||||||
let diffSeconds = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000);
|
|
||||||
|
|
||||||
// If diff is greater than 5 minutes, not a combat log
|
// If diff is greater than 5 minutes, not a combat log
|
||||||
// or if death after last combat
|
// or if death after last combat
|
||||||
|
if (diffSeconds > (data.combatLogTimer * 60)) return;
|
||||||
if (data.lastDamageDate <= data.lastDeathDate) return;
|
if (data.lastDamageDate <= data.lastDeathDate) return;
|
||||||
if (diffSeconds > 5 * 60) return;
|
|
||||||
|
|
||||||
let guild = await client.GetGuild(guildId);
|
let guild = await client.GetGuild(guildId);
|
||||||
if (!client.exists(guild.connectionLogsChannel)) return;
|
if (!client.exists(guild.connectionLogsChannel)) return;
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ module.exports = {
|
|||||||
else if (killedBy == Templates.Explosion) info.causeOfDeath = data[5];
|
else if (killedBy == Templates.Explosion) info.causeOfDeath = data[5];
|
||||||
else return stats; // Unknown template;
|
else return stats; // Unknown template;
|
||||||
|
|
||||||
let newDt = await client.getDateEST(info.time);
|
const newDt = await client.getDateEST(info.time);
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
const unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
const showCoords = client.exists(guild.showKillfeedCoords) ? guild.showKillfeedCoords : false; // default to false if no record of configuration.
|
const showCoords = client.exists(guild.showKillfeedCoords) ? guild.showKillfeedCoords : false; // default to false if no record of configuration.
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -109,6 +109,7 @@ module.exports = {
|
|||||||
lastDamageDate: playerStat.lastDamageDate,
|
lastDamageDate: playerStat.lastDamageDate,
|
||||||
lastHitBy: playerStat.lastHitBy,
|
lastHitBy: playerStat.lastHitBy,
|
||||||
lastDeathDate: playerStat.lastDeathDate,
|
lastDeathDate: playerStat.lastDeathDate,
|
||||||
|
combatLogTimer: combatLogTimer,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,9 +170,7 @@ module.exports = {
|
|||||||
let playerStatIndex = stats.indexOf(playerStat);
|
let playerStatIndex = stats.indexOf(playerStat);
|
||||||
if (playerStat === undefined) playerStat = client.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat === undefined) playerStat = client.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
|
|
||||||
const newDt = await client.getDateEST(info.time);
|
playerStat.lastDamageDate = await client.getDateEST(info.time);
|
||||||
|
|
||||||
playerStat.lastDamageDate = newDt;
|
|
||||||
playerStat.lastHitBy = info.attacker;
|
playerStat.lastHitBy = info.attacker;
|
||||||
|
|
||||||
if (playerStatIndex === -1) stats.push(playerStat);
|
if (playerStatIndex === -1) stats.push(playerStat);
|
||||||
|
|||||||
Reference in new issue
Block a user