This repository was archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
60 lines (54 loc) · 2.27 KB
/
index.js
File metadata and controls
60 lines (54 loc) · 2.27 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const centra = require('centra');
module.exports.getUser = async function (id) {
return new Promise((async (resolve, reject) => {
const res = await centra(`https://sc-network.net/api/user/${id}`, 'GET').send();
if (res.statusCode !== 200) {
return reject(res.statusCode);
}
return resolve(JSON.parse(res.body.toString()));
}));
};
module.exports.getAutoSyncMembers = async function () {
return new Promise((async (resolve, reject) => {
const res = await centra(`https://sc-network.net/api/users/autoSync`, 'GET').send();
if (res.statusCode !== 200) {
return reject(res.statusCode);
}
return resolve(JSON.parse(res.body.toString()));
}));
};
module.exports.getBetterGlobalGuild = async function (id) {
return new Promise((async (resolve, reject) => {
const res = await centra(`https://api.betterglobal.xyz/guild/${id}/stats`, 'GET').send();
if (res.statusCode !== 200) {
return reject(res.statusCode);
}
return resolve(JSON.parse(res.body.toString()));
}));
};
module.exports.getBetterGlobalUser = async function (id) {
return new Promise((async (resolve, reject) => {
const res = await centra(`https://api.betterglobal.xyz/user/${id}/stats`, 'GET').send();
if (res.statusCode !== 200) {
return reject(res.statusCode);
}
return resolve(JSON.parse(res.body.toString()));
}));
};
module.exports.getShortLink = async function (slugOrId) {
return new Promise((async (resolve, reject) => {
const res = await centra(`https://sc-network.net/api/link/${slugOrId}`, 'GET').send();
console.log(res.body.toString())
if (res.statusCode !== 200) return reject(res.statusCode);
return resolve(JSON.parse(res.body.toString()));
}));
};
module.exports.postNewShortLink = async function (authorization, body) {
return new Promise((async (resolve, reject) => {
const res = await centra('https://sc-network.net/api/link', 'POST').header('Content-Type', 'application/json').header('Authorization', 'Bearer ' + authorization).body(body, 'json').send();
if (res.statusCode !== 201) {
return reject(res.statusCode);
}
return resolve();
}));
};