2020-09-18 02:23:17 +00:00
|
|
|
// SpookVooper API - modules/premade.js
|
|
|
|
// Written by Brendan Lane
|
|
|
|
|
|
|
|
/** @module modules/premade */
|
2020-11-28 00:23:10 +00:00
|
|
|
import user from './user.js'
|
|
|
|
import eco from './eco.js'
|
2020-09-18 02:23:17 +00:00
|
|
|
|
2020-11-28 00:23:10 +00:00
|
|
|
let StockOwnerAmount
|
2020-09-18 02:23:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the total XP of a user
|
|
|
|
* @function getTotalXP
|
|
|
|
* @param {string} svid The svid of the user you want to lookup.
|
|
|
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an integer).
|
|
|
|
*/
|
2020-11-28 00:23:10 +00:00
|
|
|
function getTotalXP (svid) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
user.getUser(svid, true).then(value => {
|
|
|
|
resolve(value.post_likes + value.comment_likes + (value.twitch_message_xp * 4) + (value.discord_commends * 5) + (value.discord_message_xp * 2) + (value.discord_game_xp / 100))
|
|
|
|
})
|
|
|
|
})
|
2020-09-18 02:23:17 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 23:44:54 +00:00
|
|
|
/**
|
|
|
|
* Gets the name of the stock owner and the amount they own.
|
|
|
|
* @function getStockOwner
|
|
|
|
* @param {string} ticker The ticker you want to lookup.
|
|
|
|
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be an Object).
|
|
|
|
*/
|
2020-11-28 00:23:10 +00:00
|
|
|
function getStockOwner (ticker) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
eco.getOwnerData(ticker, true).then(value => {
|
|
|
|
StockOwnerAmount = value.length - 1
|
|
|
|
resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount })
|
2020-09-21 23:44:54 +00:00
|
|
|
})
|
2020-11-28 00:23:10 +00:00
|
|
|
})
|
2020-09-21 23:44:54 +00:00
|
|
|
}
|
|
|
|
|
2020-09-18 02:23:17 +00:00
|
|
|
export default {
|
2020-11-28 00:23:10 +00:00
|
|
|
getTotalXP,
|
|
|
|
getStockOwner
|
|
|
|
}
|