Closed jaredlyon closed 5 years ago
Added a Math.abs() function when defining the returned variable:
module.exports = {
name: 'balance',
permission: 1,
main: function(bot, msg) {
let balance = Number(bot.bank[msg.author.id].balance)
let absbalance = Math.abs(balance)
msg.reply(`your balance is **$${absbalance.toFixed(2)}**!`);
}
};
Results:
Due to the current structure of the
bank.json
file, account balances are expressed as floats, allowing for them to reach extremely small values, yet still remain negative (i.e.-0.000000001424
->$-0.00
).Currently, the three possible solutions are:
func.js
that cuts off all account balance values stored inbank.json
to the hundredths place.balance.js
module such that these values are always returned as a 'positive' zero, i.e. returning the absolute value of the account balances.