1 const google_images = require("free-google-images")
2 const common = require("./common.js")
3 let moneyStorage = common.storageLoad("money") || {}
5 const getMoney = user => moneyStorage[user] || 100
6 const setMoney = (user, money) => {
7 moneyStorage[user] = money
8 common.storageSave("money", moneyStorage)
10 const addMoney = (user, add) => setMoney(user, getMoney(user) + add)
11 const takeMoney = (user, remove) => {
12 const money = getMoney(user) - remove
23 func: (msg, [targetPing]) => {
24 const user = msg.author.id
25 const target = targetPing ? common.getPing(msg, targetPing, true) : user
28 msg.reply((user == target ? "You have " : `<@!${target}> has `) + getMoney(target) + ":b:.")
32 func: (msg, [targetPing, amountStr]) => {
33 const user = msg.author.id
34 const target = common.getPing(msg, targetPing, false)
37 const amount = parseInt(amountStr)
39 if (amount && amount > 0) {
40 if (takeMoney(user, amount)) {
41 addMoney(target, amount)
43 google_images.searchRandom("free+bobux")
44 .then(result => msg.channel.send(`<@!${target}>: <@!${user}> has payed you ${amount}:b:.\n${result.image.url}`))
46 msg.reply("You don't have enough money.")
49 msg.reply("Invalid amount of money :stuck_out_tongue:")