debug online list
This commit is contained in:
4 files changed
+38
-21
No files matched your search
@@ -21,9 +21,9 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
run: async (client, interaction, args, { GuildDB }, start) => {
|
run: async (client, interaction, args, { GuildDB }, start) => {
|
||||||
|
|
||||||
let activePlayers = GuildDB.playerstats.filter(p => p.connected);
|
let activePlayers = GuildDB.playerstats.filter(p => p.connected == true);
|
||||||
|
|
||||||
let des = ``;
|
let des = activePlayers.length > 0 ? `` : `**No Players Online**`;
|
||||||
for (let i = 0; i < activePlayers.length; i++) {
|
for (let i = 0; i < activePlayers.length; i++) {
|
||||||
des += `**- ${activePlayers[i].gamertag}\n`;
|
des += `**- ${activePlayers[i].gamertag}\n`;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "6.5.3",
|
"version": "6.5.4",
|
||||||
"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": {
|
||||||
|
|||||||
+34
-10
@@ -135,21 +135,45 @@ class DayzArmbands extends Client {
|
|||||||
let s = guild.playerstats;
|
let s = guild.playerstats;
|
||||||
|
|
||||||
for (let i = logIndex + 1; i < lines.length; i++) {
|
for (let i = logIndex + 1; i < lines.length; i++) {
|
||||||
for (let j = 0; j < s.length; j++) {
|
|
||||||
if (!s[j].connected) continue;
|
|
||||||
let inLog = false;
|
|
||||||
let connected = true;
|
|
||||||
if (lines[i].includes(s[j].gamertag)) {
|
|
||||||
inLog = true;
|
|
||||||
connected = lines[i].includes(' connected') ? true : lines[i].includes('disconnected') ? false : connected;
|
|
||||||
}
|
|
||||||
if (!inLog || !connected) s[j].connected = false;
|
|
||||||
}
|
|
||||||
if (lines[i].includes("Unknown")) continue;
|
if (lines[i].includes("Unknown")) continue;
|
||||||
if (lines[i].includes('connected') || lines[i].includes('pos=<') || lines[1].includes['hit by Player']) s = await HandlePlayerLogs(this, guildId, s, lines[i]);
|
if (lines[i].includes('connected') || lines[i].includes('pos=<') || lines[1].includes['hit by Player']) s = await HandlePlayerLogs(this, guildId, s, lines[i]);
|
||||||
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]);
|
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
|
||||||
|
s.map(p => p.connected = false) // make all connections false
|
||||||
|
|
||||||
|
for (let i = lines.length; i > 0; i--) {
|
||||||
|
if (lines[i].includes('PlayerList log:')) {
|
||||||
|
for (let j = i + 1; i < lines.length; j++) {
|
||||||
|
let line = lines[j];
|
||||||
|
if (line.includes('| ####')) break;
|
||||||
|
|
||||||
|
let data = [...line.matchAll(playerTemplate)][0];
|
||||||
|
if (!data) continue;
|
||||||
|
|
||||||
|
let info = {
|
||||||
|
time: data[1],
|
||||||
|
player: data[2],
|
||||||
|
playerID: data[3],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!this.exists(info.player) || !this.exists(info.playerID)) continue;
|
||||||
|
|
||||||
|
let playerStat = s.find(stat => stat.playerID == info.playerID)
|
||||||
|
let playerStatIndex = s.indexOf(playerStat);
|
||||||
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
|
|
||||||
|
playerStat.connected = true;
|
||||||
|
|
||||||
|
if (playerStatIndex == -1) s.push(playerStat);
|
||||||
|
else s[playerStatIndex] = playerStat;
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
await this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
||||||
$set: {
|
$set: {
|
||||||
"server.playerstats": s
|
"server.playerstats": s
|
||||||
|
|||||||
+1
-8
@@ -32,7 +32,6 @@ module.exports = {
|
|||||||
let newDt = await client.getDateEST(info.time);
|
let newDt = await client.getDateEST(info.time);
|
||||||
|
|
||||||
playerStat.lastConnectionDate = newDt;
|
playerStat.lastConnectionDate = newDt;
|
||||||
playerStat.connected = true;
|
|
||||||
|
|
||||||
if (playerStatIndex == -1) stats.push(playerStat);
|
if (playerStatIndex == -1) stats.push(playerStat);
|
||||||
else stats[playerStatIndex] = playerStat;
|
else stats[playerStatIndex] = playerStat;
|
||||||
@@ -59,14 +58,8 @@ module.exports = {
|
|||||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return stats;
|
if (!client.exists(info.player) || !client.exists(info.playerID)) return stats;
|
||||||
|
|
||||||
let playerStat = stats.find(stat => stat.playerID == info.playerID)
|
let playerStat = stats.find(stat => stat.playerID == info.playerID)
|
||||||
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);
|
||||||
|
|
||||||
playerStat.connected = false;
|
|
||||||
|
|
||||||
if (playerStatIndex == -1) stats.push(playerStat);
|
|
||||||
else stats[playerStatIndex] = playerStat;
|
|
||||||
|
|
||||||
SendConnectionLogs(client, guildId, {
|
SendConnectionLogs(client, guildId, {
|
||||||
time: info.time,
|
time: info.time,
|
||||||
player: info.player,
|
player: info.player,
|
||||||
@@ -155,7 +148,7 @@ module.exports = {
|
|||||||
|
|
||||||
const channel = client.channels.cache.get(guild.activePlayersChannel);
|
const channel = client.channels.cache.get(guild.activePlayersChannel);
|
||||||
|
|
||||||
let activePlayers = guild.playerstats.filter(p => p.connected);
|
let activePlayers = guild.playerstats.filter(p => p.connected == true);
|
||||||
|
|
||||||
if (activePlayers.length == 0) return;
|
if (activePlayers.length == 0) return;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user