From 646ef11abd38d1f4445f2d9f1ecbf07233a5aeca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Gro=C3=9F?= Date: Mon, 13 Mar 2023 16:22:07 +0100 Subject: [PATCH] Cooldown: Use Discord countdown tags for cooldowns Closes #37 --- commands/cooldowns.js | 4 ++-- util/users.js | 22 +++------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/commands/cooldowns.js b/commands/cooldowns.js index fbca5b7..135fb0b 100644 --- a/commands/cooldowns.js +++ b/commands/cooldowns.js @@ -19,13 +19,13 @@ module.exports = { if (cooldowns.remainingDrops > 0) { reply += `Drop: ${cooldowns.remainingDrops} remaining\n`; } else { - reply += `Drop: Resets in ${cooldowns.nextDropResetFormatted}\n`; + reply += `Drop: Reset ${cooldowns.nextDropResetFormatted}\n`; } if (cooldowns.remainingClaims > 0) { reply += `Claim: ${cooldowns.remainingClaims} remaining\n`; } else { - reply += `Claim: Resets in ${cooldowns.nextClaimResetFormatted}\n`; + reply += `Claim: Reset ${cooldowns.nextClaimResetFormatted}\n`; } if (cooldowns.nextDaily > 0) { diff --git a/util/users.js b/util/users.js index de608f0..9dd006c 100644 --- a/util/users.js +++ b/util/users.js @@ -48,7 +48,6 @@ module.exports = { //Claims reply['nextClaimReset'] = Math.max(user['nextClaimReset'].getTime() - reply['now'], 0); - reply['nextClaimTStamp'] = user['nextClaimReset'].getTime(); //No remamning claims but reset reached if (user['remainingClaims'] <= 0 && reply['nextClaimReset'] <= 0) { @@ -58,7 +57,6 @@ module.exports = { //Drops reply['nextDropReset'] = Math.max(user['nextDropReset'].getTime() - reply['now'], 0); - reply['nextDropTStamp'] = user['nextDropReset'].getTime(); //No remamning claims but reset reached if (user['remainingDrops'] <= 0 && reply['nextDropReset'] <= 0) { user['remainingDrops'] = 1 + (tier ? PATREON.tiers[tier].modifiers.drops : 0); @@ -69,25 +67,11 @@ module.exports = { reply['nextDaily'] = Math.max(user['nextDaily'].getTime() - reply['now'], 0); reply['nextDailyTStamp'] = user['nextDaily'].getTime(); - reply[`nextDailyFormatted`] = reply['nextDaily'] > 0 ? `` : `Ready!`; + reply[`nextDailyFormatted`] = reply['nextDaily'] > 0 ? `` : `Ready!`; for (key of cooldownKeys) { + let cooldown = reply[key]; reply[`${key}Timestamp`] = user[key].getTime(); - let cooldown = reply[key] - let hours = Math.floor(cooldown / 3600000); - let minutes = Math.floor((cooldown % 3600000) / 60000); - let seconds = Math.floor((cooldown % 60000) / 1000); - if (cooldown > 0) { - reply[`${key}Formatted`] = `${(hours >= 1 ? `${hours} hour${hours > 1 ? 's' : ''} ` : '')}` - if (minutes > 0) { - reply[`${key}Formatted`] += `${minutes} minute${minutes > 1 ? 's' : ''} `; - } - if (seconds > 0) { - reply[`${key}Formatted`] += `${seconds} second${seconds > 1 ? 's' : ''}`; - } - - } else { - reply[`${key}Formatted`] = `Ready! `; - } + reply[`${key}Formatted`] = cooldown > 0 ? `` : `Ready!`; } //Persists any potential resets