Skip to content

Commit

Permalink
Hopefully fix min/max amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMonDon committed Jul 22, 2024
1 parent a18c160 commit bff7bad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions commands/Economy/crime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
20 changes: 12 additions & 8 deletions commands/Economy/slut.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -75,21 +72,28 @@ 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] });

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)
Expand Down
4 changes: 2 additions & 2 deletions commands/Economy/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)) || '$';
Expand Down

0 comments on commit bff7bad

Please sign in to comment.