Skip to content

Commit 154698b

Browse files
authored
Merge pull request #152 from oof2win2/master
2 parents 3a844cd + 18e2429 commit 154698b

File tree

4 files changed

+82
-71
lines changed

4 files changed

+82
-71
lines changed

src/commands/Factorio/statsg.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Message, MessageEmbed } from "discord.js";
22
import { Command } from "../../base/Command.js";
3+
import mongoose from "mongoose";
34

45
const StatsG: Command<Message> = {
56
name: "statsg",
@@ -22,29 +23,41 @@ const StatsG: Command<Message> = {
2223
if (!client.users.cache.get(userID))
2324
return message.reply(`User <@${userID}> doesn't exist!`);
2425
let user = await client.findOrCreateUser({ id: userID });
25-
if (!user.factorioName) return message.reply("User is not linked!");
26+
if (!user.factorioName)
27+
return message.reply(`User <@${userID}> is not linked to Factorio!`);
28+
29+
const data = await mongoose.connections[1]
30+
.getClient()
31+
.db("scenario")
32+
.collection("PlayerData")
33+
.findOne({
34+
playername: user.factorioName,
35+
});
36+
37+
console.log(data.data);
38+
if (!data.data || !data.data.Statistics)
39+
return message.reply(`User <@${userID}> has no stats!`);
40+
const { Statistics } = data.data;
2641

2742
let embed = new MessageEmbed()
28-
.setAuthor(message.guild.name, message.guild.iconURL())
43+
.setAuthor({ name: message.guild.name, iconURL: message.guild.iconURL() })
2944
.setColor(client.config.embed.color)
3045
.setFooter(client.config.embed.footer);
3146
embed.setTitle("Global Factorio User Statistics");
3247
embed.setDescription(`Statistics of <@${userID}> | ${userID}`);
3348
embed.addFields([
3449
{
35-
name: "Total Points",
36-
value: Math.round(user.factorioStats.points).toString(),
50+
name: "Damage dealt",
51+
value: (Statistics.DamageDealt ?? 0).toString(),
3752
},
38-
{ name: "Deaths", value: user.factorioStats.deaths.toString() },
53+
{ name: "Deaths", value: (Statistics.Deaths ?? 0).toString() },
3954
{
4055
name: "Built Entities",
41-
value: user.factorioStats.builtEntities.toString(),
56+
value: (Statistics.MachinesBuilt ?? 0).toString(),
4257
},
4358
{
4459
name: "Time played (minutes)",
45-
value: Math.round(
46-
(user.factorioStats.timePlayed / 54000) * 15
47-
).toString(),
60+
value: (Statistics.Playtime ?? 0).toString(),
4861
},
4962
]);
5063
return message.channel.send({

src/helpers/serverHandler.ts

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -285,22 +285,22 @@ class serverHandler {
285285
}
286286
).exec();
287287
}
288-
if (line.includes("DIED")) {
289-
line = line.slice("DIED: ".length);
290-
const newline = line.split(" "); //split at separation between username and death reson
291-
if (newline[0] == "PLAYER:") newline.shift();
292-
this.appendMessage(
293-
server,
294-
`${this.client.emotes?.playerdeath} ${newline[0]} died due to ${newline[1]}`
295-
);
288+
// if (line.includes("DIED")) {
289+
// line = line.slice("DIED: ".length);
290+
// const newline = line.split(" "); //split at separation between username and death reson
291+
// if (newline[0] == "PLAYER:") newline.shift();
292+
// this.appendMessage(
293+
// server,
294+
// `${this.client.emotes?.playerdeath} ${newline[0]} died due to ${newline[1]}`
295+
// );
296296

297-
let user = await this.client.findUserFactorioName(newline[0]);
298-
if (user) {
299-
user.factorioStats.deaths++;
300-
user.factorioStats.points -= 100;
301-
user.save();
302-
}
303-
}
297+
// let user = await this.client.findUserFactorioName(newline[0]);
298+
// if (user) {
299+
// user.factorioStats.deaths++;
300+
// user.factorioStats.points -= 100;
301+
// user.save();
302+
// }
303+
// }
304304
if (line.includes("ROCKET: ")) {
305305
let serverStats = await ServerStatistics.findOneAndUpdate(
306306
{ serverID: server.discordid },
@@ -364,51 +364,51 @@ class serverHandler {
364364
).then(() => {});
365365
}
366366
}
367-
if (line.includes("STATS: ")) {
368-
let tmp = line
369-
.slice(line.indexOf("STATS: ") + "STATS: ".length)
370-
.split(" ");
371-
let playername = tmp.shift();
372-
let builtEntities = parseInt(tmp.shift());
373-
let playTime = parseInt(tmp.shift());
374-
let user = await this.client.findUserFactorioName(playername);
375-
if (!user) return; // don't run on people who don't have stuff
376-
const addHoursPlayed = playTime / 54000 / 4; // 54000 ticks in 15 mins, 15*60*60, 60 minutes in an hour
377-
const totHoursPlayed =
378-
(playTime + user.factorioStats.timePlayed) / 54000 / 4;
379-
user.factorioStats.builtEntities += builtEntities;
380-
user.factorioStats.timePlayed += playTime;
381-
user.factorioStats.points += builtEntities;
382-
user.factorioStats.points += addHoursPlayed * 50;
383-
if (totHoursPlayed > this.client.consts.veteranUserHours) {
384-
if (
385-
!user.factorioRoles.includes(
386-
this.client.config.factorioRoles.veteran.name
387-
)
388-
) {
389-
// add Veteran role on Discord
390-
this.client.guilds
391-
.resolve(this.client.consts.guildid)
392-
.members.fetch(user.id)
393-
.then((member) => {
394-
member.roles
395-
.add(this.client.config.factorioRoles.veteran.id)
396-
.catch(() => {});
397-
})
398-
.catch(() => {});
399-
user.factorioRoles.push(
400-
this.client.config.factorioRoles.veteran.name
401-
); // add role to DB
402-
user
403-
.save()
404-
.then(() => this.assignRoles(playername, server).then(() => {})); // assign roles in-game
405-
} else {
406-
user.save();
407-
}
408-
} else {
409-
user.save();
410-
}
411-
}
367+
// if (line.includes("STATS: ")) {
368+
// let tmp = line
369+
// .slice(line.indexOf("STATS: ") + "STATS: ".length)
370+
// .split(" ");
371+
// let playername = tmp.shift();
372+
// let builtEntities = parseInt(tmp.shift());
373+
// let playTime = parseInt(tmp.shift());
374+
// let user = await this.client.findUserFactorioName(playername);
375+
// if (!user) return; // don't run on people who don't have stuff
376+
// const addHoursPlayed = playTime / 54000 / 4; // 54000 ticks in 15 mins, 15*60*60, 60 minutes in an hour
377+
// const totHoursPlayed =
378+
// (playTime + user.factorioStats.timePlayed) / 54000 / 4;
379+
// user.factorioStats.builtEntities += builtEntities;
380+
// user.factorioStats.timePlayed += playTime;
381+
// user.factorioStats.points += builtEntities;
382+
// user.factorioStats.points += addHoursPlayed * 50;
383+
// if (totHoursPlayed > this.client.consts.veteranUserHours) {
384+
// if (
385+
// !user.factorioRoles.includes(
386+
// this.client.config.factorioRoles.veteran.name
387+
// )
388+
// ) {
389+
// // add Veteran role on Discord
390+
// this.client.guilds
391+
// .resolve(this.client.consts.guildid)
392+
// .members.fetch(user.id)
393+
// .then((member) => {
394+
// member.roles
395+
// .add(this.client.config.factorioRoles.veteran.id)
396+
// .catch(() => {});
397+
// })
398+
// .catch(() => {});
399+
// user.factorioRoles.push(
400+
// this.client.config.factorioRoles.veteran.name
401+
// ); // add role to DB
402+
// user
403+
// .save()
404+
// .then(() => this.assignRoles(playername, server).then(() => {})); // assign roles in-game
405+
// } else {
406+
// user.save();
407+
// }
408+
// } else {
409+
// user.save();
410+
// }
411+
// }
412412
}
413413
async awfLogging(data: OutputData) {
414414
let line = JSON.parse(data.line);

src/storage/computerAppsCorrect.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/storage/podNumbers.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)