-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
spigotapi.js
35 lines (33 loc) · 1.06 KB
/
spigotapi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const axios = require("axios");
module.exports.getResource = function (id) {
return axios.get("https://api.spigotmc.org/simple/0.1/index.php?action=getResource&id=" + id, {
headers: {
"User-Agent": "spiget"
}
}).then(response => {
const s = response.data;
const d = {};
if (s.title) d.name = s.title;
if (s.tag) d.tag = s.tag;
if (s.stats) {
if (s.stats.downloads) d.downloads = Number(s.stats.downloads);
}
if (s.premium) {
if (s.premium.price) d.price = Number(s.premium.price);
if (s.premium.currency) d.currency = s.premium.currency;
}
return d;
})
};
// module.exports.getLatestResourceVersion = function (id) {
// return axios.get("https://api.spigotmc.org/simple/0.1/index.php?action=getResource&id=" + id, {
// headers: {
// "User-Agent": "spiget"
// }
// }).then(response => {
// const s = response.data;
// const d = {};
// //TODO
// return d;
// })
// };