Skip to content

Commit

Permalink
update user balance on level up
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoins committed Apr 14, 2018
1 parent 7e5ecd8 commit eb85ef9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
27 changes: 20 additions & 7 deletions dist/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 23 additions & 7 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,38 @@ export const giveXp = async (user: NatsukiUser, message: Message) => {
leveledup = true
}

const route = `${baseRoute}/${message.author.id}/level?token=${api.token}`

if (leveledup) {
const popcornEmoji = '🍿'
const dollarEmoji = '💵'
const rewardAmount = getRandomNumber(45, 55) + level * 1.25
message.channel.send(`**${popcornEmoji} | ${message.member.displayName} just advanced to level ${level} and earned ${dollarEmoji} ${rewardAmount} credits!**`)

// TODO: Uncomment when API supports User Balance.
// user.money.balance += 50
// user.money.netWorth += 50
// await userController.updateBalance(message.member.id, user.money.balance, user.money.networth).catch(Logger.error)
user.balance.balance += 50
user.balance.netWorth += 50

const postData = {
level: {
xp: experience,
level
},
balance: {
balance: user.balance.balance,
netWorth: user.balance.netWorth,
dateLastClaimedDailies: user.balance.dateLastClaimedDailies
}
}

axios.put(route, postData).catch(Logger.error)
return
}

const route = `${baseRoute}/${message.author.id}/level?token=${api.token}`
const postData = {
xp: experience,
level
level: {
xp: experience,
level
}
}

axios.put(route, postData).catch(Logger.error)
Expand Down

0 comments on commit eb85ef9

Please sign in to comment.