From bff7bad68a97b354279717b326341440950afb05 Mon Sep 17 00:00:00 2001 From: TheMonDon <11539895+TheMonDon@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:28:22 -0500 Subject: [PATCH] Hopefully fix min/max amounts --- commands/Economy/crime.js | 8 ++++---- commands/Economy/slut.js | 20 ++++++++++++-------- commands/Economy/work.js | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/commands/Economy/crime.js b/commands/Economy/crime.js index b999ffdd..4ca7541a 100755 --- a/commands/Economy/crime.js +++ b/commands/Economy/crime.js @@ -52,12 +52,12 @@ class Crime extends Command { const authNet = cash + bank; // Get the min and max amounts of money the user can get - const min = (await db.get(`servers.${msg.guild.id}.economy.${type}.min`)) || 500; - const max = (await db.get(`servers.${msg.guild.id}.economy.${type}.max`)) || 2000; + const min = Number(await db.get(`servers.${msg.guild.id}.economy.${type}.min`)) || 500; + const max = Number(await db.get(`servers.${msg.guild.id}.economy.${type}.max`)) || 2000; // Get the min and max fine percentages - const minFine = (await db.get(`servers.${msg.guild.id}.economy.${type}.fine.min`)) || 10; - const maxFine = (await db.get(`servers.${msg.guild.id}.economy.${type}.fine.max`)) || 30; + const minFine = Number(await db.get(`servers.${msg.guild.id}.economy.${type}.fine.min`)) || 10; + const maxFine = Number(await db.get(`servers.${msg.guild.id}.economy.${type}.fine.max`)) || 30; // randomFine is a random number between the minimum and maximum fail rate const randomFine = BigInt(Math.abs(Math.round(Math.random() * (maxFine - minFine + 1) + minFine))); diff --git a/commands/Economy/slut.js b/commands/Economy/slut.js index c217c7c8..2d8423d3 100644 --- a/commands/Economy/slut.js +++ b/commands/Economy/slut.js @@ -50,9 +50,6 @@ class Slut extends Command { const bank = BigInt((await db.get(`servers.${msg.guild.id}.users.${msg.member.id}.economy.bank`)) || 0); const authNet = cash + bank; - const min = (await db.get(`servers.${msg.guild.id}.economy.${type}.min`)) || 500; - const max = (await db.get(`servers.${msg.guild.id}.economy.${type}.max`)) || 2000; - // Get the min and max fine percentages const minFine = (await db.get(`servers.${msg.guild.id}.economy.${type}.fine.min`)) || 10; const maxFine = (await db.get(`servers.${msg.guild.id}.economy.${type}.fine.max`)) || 30; @@ -75,9 +72,11 @@ class Slut extends Command { const crimeFail = require('../../resources/messages/slut_fail.json'); if (ranNum < failRate) { - const csamount = currencySymbol + fineAmount.toLocaleString(); + let csAmount = currencySymbol + fineAmount.toLocaleString(); + csAmount = csAmount.length > 1024 ? csAmount.slice(0, 1021) + '...' : csAmount; + const num = Math.floor(Math.random() * (crimeFail.length - 1)) + 1; - const txt = crimeFail[num].replace('csamount', csamount); + const txt = crimeFail[num].replace('csamount', csAmount); embed.setDescription(txt).setFooter({ text: `Reply #${num.toLocaleString()}` }); msg.channel.send({ embeds: [embed] }); @@ -85,11 +84,16 @@ class Slut extends Command { const newAmount = cash - fineAmount; await db.set(`servers.${msg.guild.id}.users.${msg.member.id}.economy.cash`, newAmount.toString()); } else { - const amount = BigInt(Math.abs(Math.floor(Math.random() * (max - min + 1) + min))); - const csamount = currencySymbol + amount.toLocaleString(); + const min = Number(await db.get(`servers.${msg.guild.id}.economy.${type}.min`)) || 500; + const max = Number(await db.get(`servers.${msg.guild.id}.economy.${type}.max`)) || 2000; + + const amount = BigInt(Math.floor(Math.random() * (max - min + 1) + min)); + + let csAmount = currencySymbol + amount.toLocaleString(); + csAmount = csAmount.length > 1024 ? csAmount.slice(0, 1021) + '...' : csAmount; const num = Math.floor(Math.random() * (crimeSuccess.length - 1)) + 1; - const txt = crimeSuccess[num].replace('csamount', csamount); + const txt = crimeSuccess[num].replace('csamount', csAmount); embed .setDescription(txt) diff --git a/commands/Economy/work.js b/commands/Economy/work.js index 4acfbc05..5d63c566 100755 --- a/commands/Economy/work.js +++ b/commands/Economy/work.js @@ -38,8 +38,8 @@ class Work extends Command { } } - const min = parseFloat((await db.get(`servers.${msg.guild.id}.economy.work.min`)) || 50); - const max = parseFloat((await db.get(`servers.${msg.guild.id}.economy.work.max`)) || 500); + const min = Number(await db.get(`servers.${msg.guild.id}.economy.work.min`)) || 50; + const max = Number(await db.get(`servers.${msg.guild.id}.economy.work.max`)) || 500; const amount = Math.abs(Math.floor(Math.random() * (max - min + 1) + min)); const currencySymbol = (await db.get(`servers.${msg.guild.id}.economy.symbol`)) || '$';