'How can I multiply the amount in the data of user?
I was trying to make a russian roulette then if I the did rr all then all of their balance would be multiplied when they won, but doing data.wallet * 2 isn't working. How can I do that?
economy.findOneAndUpdate({
guildID: message.guild.id,
userID: message.author.id
}, {$inc: {wallet: amount }}, async(err, data) => {
if(data) {
data.wallet * 2
data.save()
}
})
Solution 1:[1]
You can use {$mul} to multiply current balance.
economy.findOneAndUpdate({
guildID: message.guild.id,
userID: message.author.id
}, {$mul: {wallet: 2}}, async(err, data) => { //This is how you can multiply the balance wallet: 2 then save it as
if(data) {
data.wallet * 2 //like this
data.save()
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | æ–°Acesyyy |
