From d92c25228b87bc13ebc852eb8c569e2ad63fad04 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Wed, 29 May 2024 19:08:26 +0500 Subject: [PATCH] fix saving data (PLEASEEEEEEEEEEE) --- commands/Economy/marry.js | 2 ++ commands/Economy/transactions.js | 1 + commands/Economy/work.js | 10 ++++++---- commands/Moderation/clearwarns.js | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/commands/Economy/marry.js b/commands/Economy/marry.js index a03a6673..5b854e0d 100644 --- a/commands/Economy/marry.js +++ b/commands/Economy/marry.js @@ -146,6 +146,8 @@ class Marry extends BaseCommand { userData.achievements.married.progress.now = 1; } + userData.markModified("achievements"); + otherUserData.markModified("achievements"); await userData.save(); await otherUserData.save(); diff --git a/commands/Economy/transactions.js b/commands/Economy/transactions.js index a2716fa8..9af4932b 100644 --- a/commands/Economy/transactions.js +++ b/commands/Economy/transactions.js @@ -41,6 +41,7 @@ class Transactions extends BaseCommand { if (interaction.options.getBoolean("clear")) { memberData.transactions = []; + memberData.markModified("transactions"); await memberData.save(); return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true }); diff --git a/commands/Economy/work.js b/commands/Economy/work.js index d45491ae..9b0b7e41 100644 --- a/commands/Economy/work.js +++ b/commands/Economy/work.js @@ -30,14 +30,14 @@ class Work extends BaseCommand { const { member: memberData, user: userData } = interaction.data, isInCooldown = memberData.cooldowns?.work; - if (isInCooldown && isInCooldown > 0 && isInCooldown > Math.floor(Date.now() / 1000)) + if (isInCooldown && isInCooldown > Date.now()) return interaction.error("economy/work:COOLDOWN", { - time: ``, + time: ``, }); - if (Math.floor(Date.now() / 1000) > Math.floor(memberData.cooldowns.work + 30 * 60 * 60)) memberData.workStreak = 0; + if (Date.now() > memberData.cooldowns.work + 30 * 60 * 60 * 1000) memberData.workStreak = 0; - memberData.cooldowns.work = Math.floor(Date.now() / 1000) + 24 * 60 * 60; // 24 hours + memberData.cooldowns.work = Date.now() + 24 * 60 * 60 * 1000; memberData.workStreak = (memberData.workStreak || 0) + 1; const embed = client.embed({ @@ -113,9 +113,11 @@ class Work extends BaseCommand { userData.achievements.work.achieved = true; } + userData.markModified("achievements"); await userData.save(); } + memberData.markModified("cooldowns"); await memberData.save(); interaction.reply(messageOptions); diff --git a/commands/Moderation/clearwarns.js b/commands/Moderation/clearwarns.js index cc7e3c2c..ba13d17e 100644 --- a/commands/Moderation/clearwarns.js +++ b/commands/Moderation/clearwarns.js @@ -44,6 +44,7 @@ class Clearwarns extends BaseCommand { memberData.sanctions = []; + memberData.markModified("sanctions"); await memberData.save(); interaction.success("moderation/clearwarns:SUCCESS", {