-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
74 lines (56 loc) · 1.72 KB
/
main.js
File metadata and controls
74 lines (56 loc) · 1.72 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const fetch = require('node-fetch');
async function ping(mcip) {
// var ip;
// if (!port) {
// ip = mcip
// } else {
// ip = `${mcip}:${mcport}`
// }
const info1 = await fetch(`https://api.mcsrvstat.us/2/${mcip}`);
const server = await info1.json();
return server;
}
async function logo(mcip, port) {
let mcport;
if (!port) {
mcport = 25565
} else {
mcport = port
}
const res = await fetch(`https://eu.mc-api.net/v3/server/favicon/${mcip}:${mcport}`)
var loginfo;
if (res.statusText === "Not Found") {
loginfo = 'Not Found'
statcode = 404
} else {
loginfo = `https://eu.mc-api.net/v3/server/favicon/${mcip}:${mcport}`
statcode = 200
}
const logo = {
favicon: loginfo,
code: statcode
}
return logo;
}
async function player(mcname) {
const fplayer = await fetch(`https://api.mojang.com/users/profiles/minecraft/${mcname}`)
const infoplayer = await fplayer.json()
const uuid = infoplayer.id
const fhist = await fetch(`https://api.mojang.com/user/profiles/${uuid}/names`)
const hist = await fhist.json()
const info = {
pseudo: infoplayer.name,
uuid: uuid,
names: hist.map(r => r.name),
skin: {
avatars: `https://crafatar.com/avatars/${uuid}`,
head: `https://crafatar.com/renders/head/${uuid}`,
body: `https://crafatar.com/renders/body/${uuid}`,
skin: `https://crafatar.com/skins/${uuid}`
}
}
return info;
}
module.exports.ping = ping;
module.exports.logo = logo;
module.exports.player = player;