-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil.js
More file actions
29 lines (24 loc) · 760 Bytes
/
util.js
File metadata and controls
29 lines (24 loc) · 760 Bytes
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
const request = require("request");
function checkUsername(username) {
return new Promise((resolve, reject) => {
request("https://api.mojang.com/users/profiles/minecraft/" + username, function (err, res, body) {
if (err||res.status === 204) {
reject();
return;
}
try {
let json = JSON.parse(body);
resolve(json["id"]);
} catch (e){
reject(e);
}
})
})
}
function base64encode(string) {
return Buffer.from(string).toString("base64");
}
function base64decode(string) {
return Buffer.from(string, "base64").toString("utf8");
}
module.exports = {checkUsername,base64encode,base64decode};