refactor/commands support migrates player stats
This commit is contained in:
17 files changed
+169
-284
No files matched your search
@@ -205,9 +205,9 @@ module.exports = {
|
||||
|
||||
let info = {
|
||||
time: data[1],
|
||||
victim: data[2],
|
||||
victimID: data[3],
|
||||
victimPOS: data[4].split(', ').map(v => parseFloat(v)),
|
||||
player: data[2],
|
||||
playerID: data[3],
|
||||
playerPOS: data[4].split(', ').map(v => parseFloat(v)),
|
||||
};
|
||||
|
||||
for (let i = 0; i < guild.alarms.length; i++) {
|
||||
|
||||
@@ -191,13 +191,13 @@ module.exports = {
|
||||
let banking = await client.dbo.collection("users").findOne({"user.userID": killerStat.discordID}).then(banking => banking);
|
||||
|
||||
if (!banking) {
|
||||
banking = await createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, client)
|
||||
banking = await createUser(interaction.member.user.id, guildId, guild.startingBalance, client)
|
||||
if (!client.exists(banking)) return client.sendInternalError(interaction, err);
|
||||
}
|
||||
banking = banking.user;
|
||||
|
||||
if (!client.exists(banking.guilds[GuildDB.serverID])) {
|
||||
const success = addUser(banking.guilds, GuildDB.serverID, interaction.member.user.id, client, GuildDB.startingBalance);
|
||||
if (!client.exists(banking.guilds[guildId])) {
|
||||
const success = addUser(banking.guilds, guildId, interaction.member.user.id, client, guild.startingBalance);
|
||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -30,11 +30,12 @@ module.exports = {
|
||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return;
|
||||
|
||||
let playerStat = await client.dbo.collection("players").findOne({"playerID": info.playerID});
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID);
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, client.config.Nitrado.ServerID);
|
||||
const newDt = await client.getDateEST(info.time);
|
||||
|
||||
playerStat.lastConnectionDate = newDt;
|
||||
playerStat.connected = true;
|
||||
playerStat.connections++;
|
||||
|
||||
// Track adjusted sessions this instance has handled (e.g. no bot crashes or restarts).
|
||||
if (client.playerSessions.has(info.playerID)) {
|
||||
@@ -73,7 +74,7 @@ module.exports = {
|
||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return;
|
||||
|
||||
let playerStat = await client.dbo.collection("players").findOne({"playerID": info.playerID});
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID);
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, client.config.Nitrado.ServerID);
|
||||
|
||||
const newDt = await client.getDateEST(info.time);
|
||||
const unixTime = Math.round(newDt.getTime() / 1000); // Seconds
|
||||
@@ -123,7 +124,7 @@ module.exports = {
|
||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return;
|
||||
|
||||
let playerStat = await client.dbo.collection("players").findOne({"playerID": info.playerID});
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID);
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, client.config.Nitrado.ServerID);
|
||||
if (!client.exists(playerStat.lastConnectionDate)) playerStat.lastConnectionDate = await client.getDateEST(info.time);
|
||||
|
||||
playerStat.lastPos = playerStat.pos;
|
||||
@@ -160,7 +161,7 @@ module.exports = {
|
||||
if (!client.exists(info.player) || !client.exists(info.playerID)) return;
|
||||
|
||||
let playerStat = await client.dbo.collection("players").findOne({"playerID": info.playerID});
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID);
|
||||
if (!client.exits(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, client.config.Nitrado.ServerID);
|
||||
|
||||
playerStat.lastDamageDate = await client.getDateEST(info.time);
|
||||
playerStat.lastHitBy = info.attacker;
|
||||
|
||||
Reference in new issue
Block a user