debug a whole bunch of stuff
This commit is contained in:
3 files changed
+43
-22
No files matched your search
@@ -39,17 +39,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == args[0].value );
|
let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == args[0].value );
|
||||||
if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription('**Not Found** This player cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least ` 5 minutes `.')] });
|
if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** This gamertag \` ${args[0].value} \` cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least \` 5 minutes \`.`)] });
|
||||||
|
|
||||||
playerStat.discordID = interaction.member.user.id;
|
playerStat.discordID = interaction.member.user.id;
|
||||||
|
|
||||||
let playerStatIndex = GuildDB.playerstats.indexOf(playerStat);
|
let playerStatIndex = GuildDB.playerstats.indexOf(playerStat);
|
||||||
let playerstats = GuildDB.playerstats;
|
GuildDB.playerstats[playerStatIndex] = playerStat;
|
||||||
playerstats[playerStatIndex] = playerStatIndex;
|
|
||||||
|
|
||||||
client.dbo.collectin("guilds").updateOne({ 'server.serverID': GuildDB.serverID }, {
|
client.dbo.collection("guilds").updateOne({ 'server.serverID': GuildDB.serverID }, {
|
||||||
$set: {
|
$set: {
|
||||||
'server.playerstats': playerstats,
|
'server.playerstats': GuildDB.playerstats,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ module.exports = {
|
|||||||
|
|
||||||
let connectedEmbed = new EmbedBuilder()
|
let connectedEmbed = new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default)
|
.setColor(client.config.Colors.Default)
|
||||||
.setDescription(`Successfully connected \` ${playerstats.gamertag} \` as your gamertag.`);
|
.setDescription(`Successfully connected \` ${playerStat.gamertag} \` as your gamertag.`);
|
||||||
|
|
||||||
return interaction.send({ embeds: [connectedEmbed] })
|
return interaction.send({ embeds: [connectedEmbed] })
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "5.8.2",
|
"version": "5.8.15",
|
||||||
"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": {
|
||||||
|
|||||||
+37
-15
@@ -140,6 +140,8 @@ class DayzArmbands extends Client {
|
|||||||
distance: data[12]
|
distance: data[12]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!this.exists(info.victim) || !this.exists(info.victimID) || !this.exists(info.killer) || !this.exists(info.killerID)) return;
|
||||||
|
|
||||||
let killerStat = guild.playerstats.find(stat => stat.playerID == info.killerID)
|
let killerStat = guild.playerstats.find(stat => stat.playerID == info.killerID)
|
||||||
let victimStat = guild.playerstats.find(stat => stat.playerID == info.victimID)
|
let victimStat = guild.playerstats.find(stat => stat.playerID == info.victimID)
|
||||||
let killerStatIndex = guild.playerstats.indexOf(killerStat);
|
let killerStatIndex = guild.playerstats.indexOf(killerStat);
|
||||||
@@ -196,7 +198,7 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
const newBalance = banking.guilds[guild.serverID].bankAccount.balance + totalBounty;
|
const newBalance = banking.guilds[guild.serverID].bankAccount.balance + totalBounty;
|
||||||
|
|
||||||
this.dbo.collection("users").updateOne({ "user.userID": killerStat.discordID }, {
|
await this.dbo.collection("users").updateOne({ "user.userID": killerStat.discordID }, {
|
||||||
$set: {
|
$set: {
|
||||||
[`banking.guilds.${guild.serverID}.bankAccount.balance`]: newBalance,
|
[`banking.guilds.${guild.serverID}.bankAccount.balance`]: newBalance,
|
||||||
}
|
}
|
||||||
@@ -214,7 +216,7 @@ class DayzArmbands extends Client {
|
|||||||
if (victimStatIndex == -1) guild.playerstats.push(victimStat);
|
if (victimStatIndex == -1) guild.playerstats.push(victimStat);
|
||||||
else guild.playerstats[victimStatIndex] = victimStat;
|
else guild.playerstats[victimStatIndex] = victimStat;
|
||||||
|
|
||||||
this.dbo.collection("guilds").updateOne({ "server.serverID": guild.serverID }, {
|
await this.dbo.collection("guilds").updateOne({ "server.serverID": guild.serverID }, {
|
||||||
$set: {
|
$set: {
|
||||||
"server.playerstats": guild.playerstats
|
"server.playerstats": guild.playerstats
|
||||||
}
|
}
|
||||||
@@ -232,6 +234,7 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
if (this.exists(channel)) channel.send({ embeds: [killEvent] });
|
if (this.exists(channel)) channel.send({ embeds: [killEvent] });
|
||||||
if (this.exists(receivedBounty) && this.exists(channel)) channel.send({ content: `<@${killerStat.discordID}>`, embeds: [receivedBounty] });
|
if (this.exists(receivedBounty) && this.exists(channel)) channel.send({ content: `<@${killerStat.discordID}>`, embeds: [receivedBounty] });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleAlarms(guildId, data) {
|
async handleAlarms(guildId, data) {
|
||||||
@@ -239,7 +242,7 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
if (!this.exists(guild.alarms)) {
|
if (!this.exists(guild.alarms)) {
|
||||||
guild.alarms = [];
|
guild.alarms = [];
|
||||||
this.dbo.collection("guilds").updateOne({ 'server.serverID': guildId }, {
|
await this.dbo.collection("guilds").updateOne({ 'server.serverID': guildId }, {
|
||||||
$set: {
|
$set: {
|
||||||
'server.alarms': [],
|
'server.alarms': [],
|
||||||
}
|
}
|
||||||
@@ -347,6 +350,7 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
if (line.includes(' connected')) {
|
if (line.includes(' connected')) {
|
||||||
let data = [...line.matchAll(connectTemplate)][0];
|
let data = [...line.matchAll(connectTemplate)][0];
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
let info = {
|
let info = {
|
||||||
time: data[1],
|
time: data[1],
|
||||||
@@ -355,6 +359,8 @@ class DayzArmbands extends Client {
|
|||||||
connected: true,
|
connected: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!this.exists(info.player) || !this.exists(info.playerID)) return;
|
||||||
|
|
||||||
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
||||||
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
@@ -368,7 +374,7 @@ class DayzArmbands extends Client {
|
|||||||
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
||||||
else guild.playerstats[playerStatIndex] = playerStat;
|
else guild.playerstats[playerStatIndex] = playerStat;
|
||||||
|
|
||||||
this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
await this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
||||||
$set: {
|
$set: {
|
||||||
"server.playerstats": guild.playerstats
|
"server.playerstats": guild.playerstats
|
||||||
}
|
}
|
||||||
@@ -386,6 +392,7 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
if (line.includes(' disconnected')) {
|
if (line.includes(' disconnected')) {
|
||||||
let data = [...line.matchAll(disconnectTemplate)][0];
|
let data = [...line.matchAll(disconnectTemplate)][0];
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
let info = {
|
let info = {
|
||||||
time: data[1],
|
time: data[1],
|
||||||
@@ -394,6 +401,8 @@ class DayzArmbands extends Client {
|
|||||||
connected: false
|
connected: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.exists(info.player) || !this.exists(info.playerID)) return;
|
||||||
|
|
||||||
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
||||||
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
@@ -403,7 +412,7 @@ class DayzArmbands extends Client {
|
|||||||
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
||||||
else guild.playerstats[playerStatIndex] = playerStat;
|
else guild.playerstats[playerStatIndex] = playerStat;
|
||||||
|
|
||||||
this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
await this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
||||||
$set: {
|
$set: {
|
||||||
"server.playerstats": guild.playerstats
|
"server.playerstats": guild.playerstats
|
||||||
}
|
}
|
||||||
@@ -428,14 +437,17 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
if (line.includes('pos=<')) {
|
if (line.includes('pos=<')) {
|
||||||
let data = [...line.matchAll(positionTemplate)][0];
|
let data = [...line.matchAll(positionTemplate)][0];
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
let info = {
|
let info = {
|
||||||
time: data[1],
|
time: data[1],
|
||||||
player: data[2],
|
player: data[2],
|
||||||
playerID: data[3],
|
playerID: data[3],
|
||||||
pos: data[4].split(', ').map(v => parseFloat(v)).pop()
|
pos: data[4].split(', ').map(v => parseFloat(v))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!this.exists(info.player) || !this.exists(info.playerID)) return;
|
||||||
|
|
||||||
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
||||||
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
@@ -452,7 +464,7 @@ class DayzArmbands extends Client {
|
|||||||
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
||||||
else guild.playerstats[playerStatIndex] = playerStat;
|
else guild.playerstats[playerStatIndex] = playerStat;
|
||||||
|
|
||||||
this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
await this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
||||||
$set: {
|
$set: {
|
||||||
"server.playerstats": guild.playerstats
|
"server.playerstats": guild.playerstats
|
||||||
}
|
}
|
||||||
@@ -463,6 +475,7 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
if (line.includes('hit by Player')) {
|
if (line.includes('hit by Player')) {
|
||||||
let data = [...line.matchAll(damangeTemplate)];
|
let data = [...line.matchAll(damangeTemplate)];
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
let info = {
|
let info = {
|
||||||
time: data[1],
|
time: data[1],
|
||||||
@@ -470,6 +483,8 @@ class DayzArmbands extends Client {
|
|||||||
playerID: data[3],
|
playerID: data[3],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.exists(info.player) || !this.exists(info.playerID)) return;
|
||||||
|
|
||||||
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
let playerStat = guild.playerstats.find(stat => stat.playerID == info.playerID)
|
||||||
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
let playerStatIndex = guild.playerstats.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
@@ -477,13 +492,13 @@ class DayzArmbands extends Client {
|
|||||||
let today = new Date();
|
let today = new Date();
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${info.time} EST`);
|
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${info.time} EST`);
|
||||||
|
|
||||||
playerStats.lastDamageDate = newDt;
|
playerStat.lastDamageDate = newDt;
|
||||||
playerStats.lastHitBy = data[6];
|
playerStat.lastHitBy = data[6];
|
||||||
|
|
||||||
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
if (playerStatIndex == -1) guild.playerstats.push(playerStat);
|
||||||
else guild.playerstatus[playerStatIndex] = playerStat;
|
else guild.playerstatus[playerStatIndex] = playerStat;
|
||||||
|
|
||||||
this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
await this.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {
|
||||||
$set: {
|
$set: {
|
||||||
"server.playerstats": guild.playerstats
|
"server.playerstats": guild.playerstats
|
||||||
}
|
}
|
||||||
@@ -491,6 +506,7 @@ class DayzArmbands extends Client {
|
|||||||
if (err) this.error(err);
|
if (err) this.error(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleActivePlayersList(guildId) {
|
async handleActivePlayersList(guildId) {
|
||||||
@@ -540,8 +556,8 @@ class DayzArmbands extends Client {
|
|||||||
for await (const line of rl) { lines.push(line); }
|
for await (const line of rl) { lines.push(line); }
|
||||||
|
|
||||||
for (let i = lines.indexOf(history.lastLog) + 1; i < lines.length; i++) {
|
for (let i = lines.indexOf(history.lastLog) + 1; i < lines.length; i++) {
|
||||||
if (lines[i].includes('connected') || lines[i].includes('disconnected') || lines[i].includes('pos=<')) this.handlePlayerLogs(guildId, lines[i]);
|
if (lines[i].includes('connected') || lines[i].includes('disconnected') || lines[i].includes('pos=<') || lines[1].includes['hit by Player']) await this.handlePlayerLogs(guildId, lines[i]);
|
||||||
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player')) this.handleKillfeed(guildId, lines[i]);
|
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player')) await this.handleKillfeed(guildId, lines[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
history.lastLog = lines[lines.length-1];
|
history.lastLog = lines[lines.length-1];
|
||||||
@@ -556,11 +572,12 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
await this.downloadFile(`/games/${this.config.Nitrado.UserID}/noftp/dayzxb/config/DayZServer_X1_x64.ADM`, './logs/server-logs.ADM').then(async () => {
|
await this.downloadFile(`/games/${this.config.Nitrado.UserID}/noftp/dayzxb/config/DayZServer_X1_x64.ADM`, './logs/server-logs.ADM').then(async () => {
|
||||||
await this.readLogs('1019008625269801032').then(() => {
|
await this.readLogs('1019008625269801032').then(() => {
|
||||||
if (this.activePlayersTick == 12) this.handleActivePlayersList(guild.id);
|
if (this.activePlayersTick == 12) this.handleActivePlayersList('1019008625269801032');
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
this.logsUpdateTimer(); // restart this function
|
this.logsUpdateTimer(); // restart this function
|
||||||
}, minute * 5); // restart every 5 minutes
|
// }, minute * 5); // restart every 5 minutes
|
||||||
|
}, minute / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
async connectMongo(mongoURI, dbo) {
|
async connectMongo(mongoURI, dbo) {
|
||||||
@@ -698,7 +715,9 @@ class DayzArmbands extends Client {
|
|||||||
botAdminRoles: [],
|
botAdminRoles: [],
|
||||||
playerstats: [],
|
playerstats: [],
|
||||||
alarms: [],
|
alarms: [],
|
||||||
incomeRoles: []
|
incomeRoles: [],
|
||||||
|
linkedGamertagRole: "",
|
||||||
|
startingBalance: 500,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,6 +772,9 @@ class DayzArmbands extends Client {
|
|||||||
connectionLogsChannel: guild.server.connectionLogsChannel,
|
connectionLogsChannel: guild.server.connectionLogsChannel,
|
||||||
welcomeChannel: guild.server.welcomeChannel,
|
welcomeChannel: guild.server.welcomeChannel,
|
||||||
activePlayersChannel: guild.server.activePlayersChannel,
|
activePlayersChannel: guild.server.activePlayersChannel,
|
||||||
|
linkedGamertagRole: guild.server.linkedGamertagRole,
|
||||||
|
incomeRoles: guild.server.incomeRoles,
|
||||||
|
startingBalance: guild.server.startingBalance,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user