💻 Sync with local

This commit is contained in:
Brendan Lane 2020-11-27 19:23:10 -05:00
parent 0843b004ef
commit 497b012675
11 changed files with 2472 additions and 551 deletions

View File

@ -1,13 +1,15 @@
{ {
"env": { "env": {
"commonjs": true,
"es2021": true, "es2021": true,
"node": true "node": true
}, },
"extends": "eslint:recommended", "extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": { "parserOptions": {
"ecmaVersion": 12, "ecmaVersion": 12
"sourceType": "module"
}, },
"rules": { "rules": {
"strict": 0
} }
} }

1
.gitignore vendored
View File

@ -245,3 +245,4 @@ dmypy.json
.pytype/ .pytype/
# End of https://www.toptal.com/developers/gitignore/api/node,python # End of https://www.toptal.com/developers/gitignore/api/node,python
test.js

436
main.js
View File

@ -1,16 +1,426 @@
// SpookVooper API - main.js // SpookVooper API - main.js
// Written by Brendan Lane // Written by Brendan Lane - https://brndnln.dev/
import eco from "./modules/eco.js"; const userURL = "https://api.spookvooper.com/user";
import group from "./modules/group.js"; const groupURL = "https://api.spookvooper.com/group";
import user from "./modules/user.js"; const ecoURL = "https://api.spookvooper.com/eco";
import auth from "./modules/auth.js"; const authURL = "https://spookvooper.com/oauth2";
import premade from "./modules/premade.js";
export default { const axios = require('axios');
eco, let urlReturn;
group,
user, class User {
auth, #apikey = undefined;
premade
}; constructor(svid) {
this.svid = svid
}
getUser() {
return new Promise((resolve, reject) => {
axios.get(`${userURL}/getUser?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getUsername() {
return new Promise((resolve, reject) => {
axios.get(`${userURL}/getUsername?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getBalance() {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getBalance?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
hasDiscordRole(role) {
return new Promise((resolve, reject) => {
axios.get(`${userURL}/hasDiscordRole?userid=${this.svid}&role=${role}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getDiscordRoles() {
return new Promise((resolve, reject) => {
axios.get(`${userURL}/getDiscordRoles?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getDaysSinceLastMove() {
return new Promise((resolve, reject) => {
axios.get(`${userURL}/getDaysSinceLastMove?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
setApiKey(key) {
this.#apikey = key;
}
sendCredits(amount, to, reason) {
if (typeof to === "string") {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
} else if (typeof to === "object") {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to.svid}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
} else {
throw "The 'to' parameter must be a string or an object!";
}
}
getUserStockOffers(ticker) {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getUserStockOffers?ticker=${ticker}&svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
buyStock(ticker, amount, price) {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/submitStockBuy?ticker=${ticker}&count=${amount}&price=${price}&accountid=${this.svid}&auth=${this.#apikey}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
sellStock(ticker, amount, price) {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/submitStockSell?ticker=${ticker}&count=${amount}&price=${price}&accountid=${this.svid}&auth=${this.#apikey}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
cancelStockOrder(orderid) {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/cancelOrder?orderid=${orderid}&accountid=${this.svid}&auth=${this.#apikey}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
}
class Stock {
constructor(ticker) {
this.ticker = ticker;
}
getValue() {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getStockValue?ticker=${this.ticker}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getStockBuyPrice() {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getStockBuyPrice?ticker=${this.ticker}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getQueueInfo(type) {
switch (type) {
case "BUY":
break;
case "SELL":
break;
default:
throw "Parameter 'type' must be 'BUY' or 'SELL'"
}
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getQueueInfo?ticker=${this.ticker}&type=${type}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getOwner() {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getOwnerData?ticker=${this.ticker}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
}
class District {
constructor(name) {
this.name = name;
}
getWealth(type) {
switch (type) {
case "ALL":
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getDistrictWealth?id=${this.name}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
case "USER":
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getDistrictUserWealth?id=${this.name}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
case "GROUP":
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/getDistrictGroupWealth?id=${this.name}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
default:
throw "Parameter 'type' must be 'ALL', 'USER', or 'GROUP'";
}
}
}
class Group {
#apikey = undefined;
constructor(name) {
this.name = name;
}
getGroup() {
return new Promise((resolve, reject) => {
axios.get(`${groupURL}/getGroup?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
setApiKey(key) {
this.#apikey = key;
}
sendCredits(amount, to, reason) {
if (typeof to === "string") {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
} else if (typeof to === "object") {
return new Promise((resolve, reject) => {
axios.get(`${ecoURL}/sendTransactionByIds?from=${this.svid}&to=${to.svid}&amount=${amount}&auth=${this.#apikey}&detail=${reason}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
} else {
throw "The 'to' parameter must be a string or an object!";
}
}
doesGroupExist() {
return new Promise((resolve, reject) => {
axios.get(`${groupURL}/doesGroupExist?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
getGroupMembers() {
return new Promise((resolve, reject) => {
axios.get(`${groupURL}/getGroupMembers?svid=${this.svid}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
hasGroupPermission(user, permission) {
if (typeof to === "string") {
return new Promise((resolve, reject) => {
axios.get(`${groupURL}/hasGroupPermission?svid=${this.svid}&usersvid=${user}&permission=${permission}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
} else if (typeof to === "object") {
return new Promise((resolve, reject) => {
axios.get(`${groupURL}/hasGroupPermission?svid=${this.svid}&usersvid=${user.svid}&permission=${permission}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
}
}
class Auth {
#clientsecret = undefined;
#authcode = undefined;
constructor(clientid, clientsecret) {
this.clientid = clientid;
this.#clientsecret = clientsecret;
}
genLink(redirect, scope, state) {
if (redirect === undefined || scope === undefined) {
throw "Both parameters 'redirect' and 'scope' must be defined!"
} else if (state === undefined) {
state = "";
urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`;
urlReturn = urlReturn.split(" ").join("%20");
return urlReturn;
} else {
urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`;
urlReturn = urlReturn.split(" ").join("%20");
return urlReturn;
}
}
setAuthCode(authcode) {
this.#authcode = authcode;
}
requestToken(redirect) {
return new Promise((resolve, reject) => {
axios.get(`${authURL}/requestToken?grant_type=authorization_code&code=${this.#authcode}&redirect_uri=${redirect}&client_id=${this.clientid}&client_secret=${this.#clientsecret}`)
.then(function (response) {
resolve(response.data);
})
.catch(function (error) {
reject(error);
});
});
}
}
module.exports = {
User,
Stock,
District,
Group,
Auth
}

View File

@ -2,10 +2,10 @@
// Written by Brendan Lane // Written by Brendan Lane
/** @module modules/auth */ /** @module modules/auth */
import axios from "axios"; import axios from 'axios'
let baseURL = "https://spookvooper.com/oauth2"; const baseURL = 'https://spookvooper.com/oauth2'
let urlReturn; let urlReturn
/** /**
* Generates a Oauth2 URL for you. This just builds a string and DOES NOT need a promise. For any updates on how this works, check #sv-developer in the discord server. https://discord.gg/spookvooper. Get more information at the wiki. https://github.com/bowlingballindustries/spookvooper-api/wiki/Auth#authorize * Generates a Oauth2 URL for you. This just builds a string and DOES NOT need a promise. For any updates on how this works, check #sv-developer in the discord server. https://discord.gg/spookvooper. Get more information at the wiki. https://github.com/bowlingballindustries/spookvooper-api/wiki/Auth#authorize
@ -17,19 +17,19 @@ let urlReturn;
* @param {string} state The state parameter can have anything here. Will be returned to the server upon completion. This parameter is optional. * @param {string} state The state parameter can have anything here. Will be returned to the server upon completion. This parameter is optional.
* @returns {string} Will return a string containing a link to the Oauth2 authorization page. If there is an error, it will return "ERROR: Oauth2 URL Builder - A required variable is undefined or is missing." * @returns {string} Will return a string containing a link to the Oauth2 authorization page. If there is an error, it will return "ERROR: Oauth2 URL Builder - A required variable is undefined or is missing."
*/ */
function authorize(response_type, client_id, redirect_uri, scope, state) { function authorize (response_type, client_id, redirect_uri, scope, state) {
if (response_type === undefined || client_id === undefined || redirect_uri === undefined || scope === undefined) { if (response_type === undefined || client_id === undefined || redirect_uri === undefined || scope === undefined) {
return "ERROR: Oauth2 URL Builder - A required variable is undefined or is missing."; return 'ERROR: Oauth2 URL Builder - A required variable is undefined or is missing.'
} else if (state === undefined) { } else if (state === undefined) {
state = ""; state = ''
urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`; urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`
urlReturn = urlReturn.split(" ").join("%20"); urlReturn = urlReturn.split(' ').join('%20')
return urlReturn; return urlReturn
} else { } else {
urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`; urlReturn = `${baseURL}/authorize?response_type=${response_type}&client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}&state=${state}`
urlReturn = urlReturn.split(" ").join("%20"); urlReturn = urlReturn.split(' ').join('%20')
return urlReturn; return urlReturn
} }
} }
/** /**
@ -43,23 +43,23 @@ function authorize(response_type, client_id, redirect_uri, scope, state) {
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false * @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object containing the token, expire time in seconds, and the svid of the authorized user). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object containing the token, expire time in seconds, and the svid of the authorized user).
*/ */
function requestToken(grant_type, code, redirect_uri, client_id, client_secret, errToConsole) { function requestToken (grant_type, code, redirect_uri, client_id, client_secret, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/requestToken?grant_type=${grant_type}&code=${code}&redirect_uri=${redirect_uri}&client_id=${client_id}&client_secret=${client_secret}`) axios.get(`${baseURL}/requestToken?grant_type=${grant_type}&code=${code}&redirect_uri=${redirect_uri}&client_id=${client_id}&client_secret=${client_secret}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
export default { export default {
authorize, authorize,
requestToken requestToken
}; }

View File

@ -2,9 +2,9 @@
// Written by Brendan Lane // Written by Brendan Lane
/** @module modules/eco */ /** @module modules/eco */
import axios from "axios"; import axios from 'axios'
let baseURL = "https://api.spookvooper.com/eco"; const baseURL = 'https://api.spookvooper.com/eco'
/** /**
* Gets the balance of a user, given their svid. * Gets the balance of a user, given their svid.
@ -14,20 +14,20 @@ let baseURL = "https://api.spookvooper.com/eco";
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getBalance(svid, errToConsole) { function getBalance (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getBalance?svid=${svid}`) axios.get(`${baseURL}/getBalance?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -42,20 +42,20 @@ function getBalance(svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function sendTransactionByIDs(to, from, amount, auth, detail, errToConsole) { function sendTransactionByIDs (to, from, amount, auth, detail, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/sendTransactionByIDs?to=${to}&from=${from}&amount=${amount}&auth=${auth}&detail=${detail}`) axios.get(`${baseURL}/sendTransactionByIDs?to=${to}&from=${from}&amount=${amount}&auth=${auth}&detail=${detail}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -66,20 +66,20 @@ function sendTransactionByIDs(to, from, amount, auth, detail, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getStockValue(ticker, errToConsole) { function getStockValue (ticker, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockValue?ticker=${ticker}`) axios.get(`${baseURL}/getStockValue?ticker=${ticker}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -88,25 +88,25 @@ function getStockValue(ticker, errToConsole) {
* @param {string} ticker The ticker id * @param {string} ticker The ticker id
* @param {string} type Can be "MINUTE", "HOUR", or "DAY" * @param {string} type Can be "MINUTE", "HOUR", or "DAY"
* @param {string} count How far back to go. Don't use a count over 60! * @param {string} count How far back to go. Don't use a count over 60!
* @param {string} interval Set the time interval beteen data points * @param {string} interval Set the time interval beteen data points
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false * @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
* @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 array). * @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 array).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getStockHistory(ticker, type, count, interval, errToConsole) { function getStockHistory (ticker, type, count, interval, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockHistory?ticker=${ticker}&type=${type}&count=${count}&interval=${interval}`) axios.get(`${baseURL}/getStockHistory?ticker=${ticker}&type=${type}&count=${count}&interval=${interval}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -121,20 +121,20 @@ function getStockHistory(ticker, type, count, interval, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a tesult). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a tesult).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function submitStockBuy(ticker, count, price, accountid, auth, errToConsole) { function submitStockBuy (ticker, count, price, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockBuy?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`) axios.get(`${baseURL}/submitStockBuy?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -142,27 +142,27 @@ function submitStockBuy(ticker, count, price, accountid, auth, errToConsole) {
* @function submitStockSell * @function submitStockSell
* @param {string} ticker The ticker id * @param {string} ticker The ticker id
* @param {string} count How many stocks you want to sell * @param {string} count How many stocks you want to sell
* @param {string} price How much you want to sell each stock for * @param {string} price How much you want to sell each stock for
* @param {string} accountid The SVID of the account (user or group) you'd like to sell from. * @param {string} accountid The SVID of the account (user or group) you'd like to sell from.
* @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2. * @param {string} auth API Key that has authentication to use the account specified in accountid or use oauthkey|app_secret formula for Oauth2.
* @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false * @param {boolean} errToConsole If there is an error, send it to console, instead of returning. Defaults to false
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function submitStockSell(ticker, count, price, accountid, auth, errToConsole) { function submitStockSell (ticker, count, price, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockSell?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`) axios.get(`${baseURL}/submitStockSell?ticker=${ticker}&count=${count}&price=${price}&accountid=${accountid}&auth=${auth}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -175,20 +175,20 @@ function submitStockSell(ticker, count, price, accountid, auth, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a result).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function cancelOrder(orderid, accountid, auth, errToConsole) { function cancelOrder (orderid, accountid, auth, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/submitStockBuy?orderid=${orderid}&accountid=${accountid}&auth=${auth}`) axios.get(`${baseURL}/submitStockBuy?orderid=${orderid}&accountid=${accountid}&auth=${auth}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -199,20 +199,20 @@ function cancelOrder(orderid, accountid, auth, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getStockBuyPrice(ticker, errToConsole) { function getStockBuyPrice (ticker, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getStockBuyPrice?ticker=${ticker}`) axios.get(`${baseURL}/getStockBuyPrice?ticker=${ticker}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -224,20 +224,20 @@ function getStockBuyPrice(ticker, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getQueueInfo(ticker, type, errToConsole) { function getQueueInfo (ticker, type, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getQueueInfo?ticker=${ticker}&type=${type}`) axios.get(`${baseURL}/getQueueInfo?ticker=${ticker}&type=${type}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -249,20 +249,20 @@ function getQueueInfo(ticker, type, errToConsole) {
* @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 array). * @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 array).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getUserStockOffers(ticker, svid, errToConsole) { function getUserStockOffers (ticker, svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUserStockOffers?ticker=${ticker}&svid=${svid}`) axios.get(`${baseURL}/getUserStockOffers?ticker=${ticker}&svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -273,20 +273,20 @@ function getUserStockOffers(ticker, svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getDistrictWealth(id, errToConsole) { function getDistrictWealth (id, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictWealth?id=${id}`) axios.get(`${baseURL}/getDistrictWealth?id=${id}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -297,20 +297,20 @@ function getDistrictWealth(id, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getDistrictUserWealth(id, errToConsole) { function getDistrictUserWealth (id, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictUserWealth?id=${id}`) axios.get(`${baseURL}/getDistrictUserWealth?id=${id}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -321,20 +321,20 @@ function getDistrictUserWealth(id, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a decimal).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getDistrictGroupWealth(id, errToConsole) { function getDistrictGroupWealth (id, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDistrictGroupWealth?id=${id}`) axios.get(`${baseURL}/getDistrictGroupWealth?id=${id}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -344,35 +344,35 @@ function getDistrictGroupWealth(id, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getOwnerData(ticker, errToConsole) { function getOwnerData (ticker, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getOwnerData?ticker=${ticker}`) axios.get(`${baseURL}/getOwnerData?ticker=${ticker}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
export default { export default {
getBalance, getBalance,
sendTransactionByIDs, sendTransactionByIDs,
getStockValue, getStockValue,
getStockHistory, getStockHistory,
submitStockBuy, submitStockBuy,
submitStockSell, submitStockSell,
cancelOrder, cancelOrder,
getStockBuyPrice, getStockBuyPrice,
getQueueInfo, getQueueInfo,
getUserStockOffers, getUserStockOffers,
getDistrictWealth, getDistrictWealth,
getDistrictUserWealth, getDistrictUserWealth,
getDistrictGroupWealth, getDistrictGroupWealth,
getOwnerData getOwnerData
}; }

View File

@ -2,9 +2,9 @@
// Written by Brendan Lane // Written by Brendan Lane
/** @module modules/group */ /** @module modules/group */
import axios from "axios"; import axios from 'axios'
let baseURL = "https://api.spookvooper.com/group"; const baseURL = 'https://api.spookvooper.com/group'
/** /**
* Checks if a group exists. * Checks if a group exists.
@ -14,20 +14,20 @@ let baseURL = "https://api.spookvooper.com/group";
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function doesGroupExist(svid, errToConsole) { function doesGroupExist (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/doesGroupExist?svid=${svid}`) axios.get(`${baseURL}/doesGroupExist?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -38,20 +38,20 @@ function doesGroupExist(svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getGroupMembers(svid, errToConsole) { function getGroupMembers (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getGroupMembers?svid=${svid}`) axios.get(`${baseURL}/getGroupMembers?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -64,20 +64,20 @@ function getGroupMembers(svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function hasGroupPermission(svid, usersvid, permission, errToConsole) { function hasGroupPermission (svid, usersvid, permission, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/hasGroupPermission?svid=${svid}&usersvid=${usersvid}&permission=${permission}`) axios.get(`${baseURL}/hasGroupPermission?svid=${svid}&usersvid=${usersvid}&permission=${permission}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -88,20 +88,20 @@ function hasGroupPermission(svid, usersvid, permission, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getSvidFromName(name, errToConsole) { function getSvidFromName (name, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getSvidFromName?name=${name}`) axios.get(`${baseURL}/getSvidFromName?name=${name}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -112,26 +112,26 @@ function getSvidFromName(name, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getName(svid, errToConsole) { function getName (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getName?svid=${svid}`) axios.get(`${baseURL}/getName?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
export default { export default {
doesGroupExist, doesGroupExist,
getGroupMembers, getGroupMembers,
hasGroupPermission, hasGroupPermission,
getSvidFromName, getSvidFromName,
getName getName
}; }

View File

@ -2,10 +2,10 @@
// Written by Brendan Lane // Written by Brendan Lane
/** @module modules/premade */ /** @module modules/premade */
import user from "./user.js"; import user from './user.js'
import eco from "./eco.js"; import eco from './eco.js'
let StockOwnerAmount; let StockOwnerAmount
/** /**
* Gets the total XP of a user * Gets the total XP of a user
@ -13,12 +13,12 @@ let StockOwnerAmount;
* @param {string} svid The svid of the user you want to lookup. * @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). * @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).
*/ */
function getTotalXP(svid) { function getTotalXP (svid) {
return new Promise((resolve) => { return new Promise((resolve) => {
user.getUser(svid, true).then(value => { 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)); 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))
}); })
}); })
} }
/** /**
@ -27,16 +27,16 @@ function getTotalXP(svid) {
* @param {string} ticker The ticker you want to lookup. * @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). * @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).
*/ */
function getStockOwner(ticker) { function getStockOwner (ticker) {
return new Promise((resolve) => { return new Promise((resolve) => {
eco.getOwnerData(ticker, true).then(value => { eco.getOwnerData(ticker, true).then(value => {
StockOwnerAmount = value.length - 1; StockOwnerAmount = value.length - 1
resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount }); resolve({ name: `${value[StockOwnerAmount].ownerName}`, amount: value[StockOwnerAmount].amount })
})
}) })
})
} }
export default { export default {
getTotalXP, getTotalXP,
getStockOwner getStockOwner
}; }

View File

@ -2,9 +2,9 @@
// Written by Brendan Lane // Written by Brendan Lane
/** @module modules/user */ /** @module modules/user */
import axios from "axios"; import axios from 'axios'
let baseURL = "https://api.spookvooper.com/user"; const baseURL = 'https://api.spookvooper.com/user'
/** /**
* Gets information on the user * Gets information on the user
@ -14,20 +14,20 @@ let baseURL = "https://api.spookvooper.com/user";
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getUser(svid, errToConsole) { function getUser (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUser?svid=${svid}`) axios.get(`${baseURL}/getUser?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -38,20 +38,20 @@ function getUser(svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getUsername(svid, errToConsole) { function getUsername (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUsername?svid=${svid}`) axios.get(`${baseURL}/getUsername?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -62,20 +62,20 @@ function getUsername(svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getSvidFromUsername(username, errToConsole) { function getSvidFromUsername (username, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getSvidFromUsername?username=${username}`) axios.get(`${baseURL}/getSvidFromUsername?username=${username}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -86,20 +86,20 @@ function getSvidFromUsername(username, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getUsernameFromDiscord(discordid, errToConsole) { function getUsernameFromDiscord (discordid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUsernameFromDiscord?discordid=${discordid}`) axios.get(`${baseURL}/getUsernameFromDiscord?discordid=${discordid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -110,20 +110,20 @@ function getUsernameFromDiscord(discordid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getSvidFromDiscord(discordid, errToConsole) { function getSvidFromDiscord (discordid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getSvidFromDiscord?discordid=${discordid}`) axios.get(`${baseURL}/getSvidFromDiscord?discordid=${discordid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -134,20 +134,20 @@ function getSvidFromDiscord(discordid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getUsernameFromMinecraft(minecraftid, errToConsole) { function getUsernameFromMinecraft (minecraftid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getUsernameFromMinecraft?minecraftid=${minecraftid}`) axios.get(`${baseURL}/getUsernameFromMinecraft?minecraftid=${minecraftid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -158,20 +158,20 @@ function getUsernameFromMinecraft(minecraftid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a string).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getSvidFromMinecraft(minecraftid, errToConsole) { function getSvidFromMinecraft (minecraftid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getSvidFromMinecraft?minecraftid=${minecraftid}`) axios.get(`${baseURL}/getSvidFromMinecraft?minecraftid=${minecraftid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -183,20 +183,20 @@ function getSvidFromMinecraft(minecraftid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a boolean).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function hasDiscordRole(userid, role, errToConsole) { function hasDiscordRole (userid, role, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/hasDiscordRole?userid=${userid}&role=${role}`) axios.get(`${baseURL}/hasDiscordRole?userid=${userid}&role=${role}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -207,20 +207,20 @@ function hasDiscordRole(userid, role, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a JSON Object).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getDiscordRoles(svid, errToConsole) { function getDiscordRoles (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDiscordRoles?svid=${svid}`) axios.get(`${baseURL}/getDiscordRoles?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
/** /**
@ -231,31 +231,31 @@ function getDiscordRoles(svid, errToConsole) {
* @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a integer). * @returns {string} The data from the HTTP GET request, but because of the way it's handled, will always be a string (should be a integer).
* @author Brendan Lane <me@imbl.me> * @author Brendan Lane <me@imbl.me>
*/ */
function getDaysSinceLastMove(svid, errToConsole) { function getDaysSinceLastMove (svid, errToConsole) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get(`${baseURL}/getDaysSinceLastMove?svid=${svid}`) axios.get(`${baseURL}/getDaysSinceLastMove?svid=${svid}`)
.then(function (response) { .then(function (response) {
resolve(response.data); resolve(response.data)
}) })
.catch(function (error) { .catch(function (error) {
if (errToConsole) { if (errToConsole) {
console.warn(error); console.warn(error)
} else { } else {
reject(error); reject(error)
} }
}); })
}); })
} }
export default { export default {
getUser, getUser,
getUsername, getUsername,
getSvidFromUsername, getSvidFromUsername,
getUsernameFromDiscord, getUsernameFromDiscord,
getSvidFromDiscord, getSvidFromDiscord,
getUsernameFromMinecraft, getUsernameFromMinecraft,
getSvidFromMinecraft, getSvidFromMinecraft,
hasDiscordRole, hasDiscordRole,
getDiscordRoles, getDiscordRoles,
getDaysSinceLastMove getDaysSinceLastMove
}; }

1527
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,33 @@
{ {
"name": "spookvooperapi", "name": "spookvooperapi",
"version": "1.2.0", "version": "1.3.0",
"description": "Easy to use library for the SpookVooper API", "description": "Easy to use library for the SpookVooper API",
"main": "main.js", "main": "main.js",
"type": "module", "type": "commonjs",
"scripts": { "scripts": {
"test": "node main.js" "test": "node main.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/bowlingballindustries/spookvooper-api.git" "url": "git+https://github.com/vexico/spookvooper-api.git"
}, },
"keywords": [ "keywords": [
"spookvooper", "spookvooper",
"api", "api",
"library" "library"
], ],
"author": "bTech", "author": "Vexi Technologies",
"license": "SEE LICENSE IN LICENSE", "license": "SEE LICENSE IN LICENSE",
"devDependencies": { "devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^7.9.0", "eslint": "^7.9.0",
"prettier": "^2.1.1" "prettier": "^2.1.1"
}, },
"dependencies": { "dependencies": {
"axios": "^0.20.0" "axios": "^0.20.0"
} },
"bugs": {
"url": "https://github.com/vexico/spookvooper-api/issues"
},
"homepage": "https://vexi.cc/"
} }

44
test.js
View File

@ -1,35 +1,15 @@
import svAPI from "./main.js"; const SVAPI = require('./main.js')
/* const spike = new SVAPI.User('u-2a0057e6-356a-4a49-b825-c37796cb7bd9')
svAPI.eco.getBalance("02c977bb-0a6c-4eb2-bfca-5e9101025aaf", true).then(value => { const jacob = new SVAPI.User('u-c60c6bd8-0409-4cbd-8bb8-3c87e24c55f8')
console.log(`[test.js] ${value}`); const brendan = new SVAPI.User('u-02c977bb-0a6c-4eb2-bfca-5e9101025aaf')
});
*/
svAPI.eco.getStockBuyPrice("VNB", true).then(value => { async function sex () {
console.log(`[VNB] Current Stock Buy Price: ${value}`); console.log(await brendan.getBalance())
}); console.log(await spike.getBalance())
brendan.setApiKey('api-key')
await brendan.sendCredits(1, 'u-2a0057e6-356a-4a49-b825-c37796cb7bd9', 'Testing SpookVooper API - DOWNLOAD IT NOW https://npmjs.org/package/spookvooperapi')
console.log(await brendan.getBalance())
console.log(await spike.getBalance())
svAPI.group.getSvidFromName("Bowling Ball Industries").then(value => { sex()
console.log(`Bowling Ball Industries SVID: ${value}`);
});
svAPI.user.getUser("02c977bb-0a6c-4eb2-bfca-5e9101025aaf", true).then(value => {
console.log(`[lonr] getUser.userName value: ${value}`);
});
svAPI.premade.getTotalXP("02c977bb-0a6c-4eb2-bfca-5e9101025aaf").then(value => {
console.log(`Total XP for lonr: ${value}`);
});
svAPI.eco.getOwnerData("NEWS", true).then(value => {
console.log(`[NEWS] Owner Data: ${value[0].ownerName}`);
});
svAPI.premade.getStockOwner("NEWS").then(value => {
console.log(`[NEWS] Owner: ${value.name}`)
})
console.log(`Your Oauth2 URL: ${svAPI.auth.authorize("code", "AAAA-BBBBB-CCCCC-DDDD", "https://example.com/callback", "view", "succeeded")}`);
// Intended result should be whats on this page: https://api.spookvooper.com/eco/getbalance?svid=02c977bb-0a6c-4eb2-bfca-5e9101025aaf