mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 00:35:56 +00:00
economy: never made the discounted price deductable
This commit is contained in:
parent
81544d3f65
commit
45fdb3537f
1 changed files with 11 additions and 5 deletions
|
@ -60,9 +60,9 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const discount = Math.random() < discountChance ? 0.8 : 1;
|
const discount = Math.random() < discountChance ? 0.8 : 1;
|
||||||
const price = Math.floor(item.price * discount);
|
const discountedPrice = Math.floor(item.price * discount);
|
||||||
|
|
||||||
if (userEconomy.balance < price) {
|
if (userEconomy.balance < discountedPrice) {
|
||||||
const insufficientFundsEmbed = new EmbedBuilder()
|
const insufficientFundsEmbed = new EmbedBuilder()
|
||||||
.setColor("#ff0000")
|
.setColor("#ff0000")
|
||||||
.setTitle("💸 Insufficient Funds")
|
.setTitle("💸 Insufficient Funds")
|
||||||
|
@ -75,7 +75,11 @@ module.exports = {
|
||||||
value: `${userEconomy.balance} coins`,
|
value: `${userEconomy.balance} coins`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{ name: "Item Price", value: `${price} coins`, inline: true }
|
{
|
||||||
|
name: "Item Price",
|
||||||
|
value: `${discountedPrice} coins`,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({
|
.setFooter({
|
||||||
|
@ -90,7 +94,7 @@ module.exports = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
userEconomy.balance -= price;
|
userEconomy.balance -= discountedPrice;
|
||||||
await userEconomy.save();
|
await userEconomy.save();
|
||||||
|
|
||||||
const userInventory = await UserInventory.findOne({
|
const userInventory = await UserInventory.findOne({
|
||||||
|
@ -113,7 +117,9 @@ module.exports = {
|
||||||
const successEmbed = new EmbedBuilder()
|
const successEmbed = new EmbedBuilder()
|
||||||
.setColor("#00ff00")
|
.setColor("#00ff00")
|
||||||
.setTitle("🎉 Purchase Successful")
|
.setTitle("🎉 Purchase Successful")
|
||||||
.setDescription(`You bought **${item.name}** for **${price}** coins!`)
|
.setDescription(
|
||||||
|
`You bought **${item.name}** for **${discountedPrice}** coins!`
|
||||||
|
)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: `Requested by ${user.username}`,
|
text: `Requested by ${user.username}`,
|
||||||
|
|
Loading…
Reference in a new issue