fix/save DayZ Mission to guild db for commands use

This commit is contained in:
SowinskiBraeden committed 2024-04-23 10:08:52 -07:00
1 parent fe7dc7d2f4
commit 0af1e51f50
3 files changed
+13 -7

No files matched your search

+3 -6
View File
@@ -21,7 +21,7 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID) || !client.exists(GuildDB.Nitrado.UserID) || !client.exists(GuildDB.Nitrado.Auth)) {
if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID) || !client.exists(GuildDB.Nitrado.UserID) || !client.exists(GuildDB.Nitrado.Auth) || !client.exists(GuildDB.Nitrado.Mission)) {
const warnNitradoNotInitialized = new EmbedBuilder()
.setColor(client.config.Colors.Yellow)
.setDescription("**WARNING:** The DayZ Nitrado Server has not been configured for this guild yet. This command or feature is currently unavailable.");
@@ -31,12 +31,9 @@ module.exports = {
let playerStat = await client.dbo.collection("players").findOne({"discordID": interaction.member.user.id});
if (!client.exists(playerStat)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** You haven't linked your gamertag and are unable to use this command.`)], flags: (1 << 6) });
if (!client.exists(playerStat.time)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** There is no location saved to your gamertag yet. Make sure you've logged into the server for more than **5 minutes.**`)], flags: (1 << 6)});
if (!client.exists(playerStat.time)) return interaction.send({ emeds: [
new EmbedBuilder()
.setColor(client.config.Colors.Yellow)
.setDescription(`**Not Found** There is no location saved to your gamertag yet. Make sure you've logged into the server for more than **5 minutes.**`)
] });
console.log(true);
let newDt = await client.getDateEST(playerStat.time);
let unixTime = Math.floor(newDt.getTime()/1000);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dayzr-bot",
"version": "13.0.7",
"version": "13.0.8",
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
"main": "index.js",
"nodemonConfig": {
+9
View File
@@ -93,6 +93,8 @@ class DayzRBot extends Client {
);
}
console.log(GuildDB.Nitrado);
for (const [factionID, data] of Object.entries(GuildDB.factionArmbands)) {
const guild = this.guilds.cache.get(GuildDB.serverID);
const role = guild.roles.cache.find(role => role.id == factionID);
@@ -319,6 +321,13 @@ class DayzRBot extends Client {
if (response == 1) return;
const settings = response.data.gameserver;
// Update Nitrado DayZ Mission if change is detected
if (GuildDB.Nitrado.Mission !== Missions[settings.settings.config.mission]) {
c.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: { "Nitrado.Mission": Missions[settings.settings.config.mission] }}, (err, res) => {
if (err) this.error(`Failed to save mission to guild config [${guild.serverID}] for nitrado server [${guild.Nitrado.ServerID}]`);
});
}
GuildDB.Nitrado.Mission = Missions[settings.settings.config.mission];
const filename = settings.game_specific.log_files.sort((a, b) => a.length - b.length)[0];