-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
102 lines (88 loc) · 3.16 KB
/
index.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const Profile = require("./src/structures/Profile");
const fetch = require('node-fetch');
const Level = require("./src/structures/Level");
const Song = require("./src/structures/Song");
const geoData = require('geometry-data');
async function findProfile(query) {
var profile = await fetch(`https://gdbrowser.com/api/profile/${query}`);
profile = await profile.json();
return new Profile({
username: profile.username,
playerID: profile.playerID,
accountID: profile.accountID,
rank: profile.rank,
stars: profile.stars,
diamonds: profile.diamonds,
coins: profile.coins,
userCoins: profile.userCoins,
demons: profile.demons,
creatorPoints: profile.cp,
friendRequests: profile.friendRequests,
messages: profile.messages,
commentHistory: profile.commentHistory,
moderator: profile.moderator,
youtube: profile.youtube,
twitter: profile.twitter,
twitch: profile.twitch,
cube: `https://gdbrowser.com/icon/${profile.username}`,
ship: `https://gdbrowser.com/icon/${profile.username}?form=ship`,
ball: `https://gdbrowser.com/icon/${profile.username}?form=ball`,
ufo: `https://gdbrowser.com/icon/${profile.username}?form=ufo`,
wave: `https://gdbrowser.com/icon/${profile.username}?form=wave`,
robot: `https://gdbrowser.com/icon/${profile.username}?form=robot`,
spider: `https://gdbrowser.com/icon/${profile.username}?form=spider`,
deathEffect: profile.deathEffect,
glow: profile.glow
});
}
async function findLevel(levelID){
var level;
await fetch(`https://gdbrowser.com/api/level/${levelID}`)
.then(response => response.json())
.then(data => {
level = data;
});
var customSong;
if(level.customSong == 0){
customSong = false;
} else {
customSong = true
}
return new Level({
name: level.name,
id: level.id,
description: level.description,
author: findProfile(level.accountID),
difficulty: level.difficulty,
difficultyPng: `https://gdbrowser.com/assets/difficulties/${level.difficulty}.png`,
downloads: level.downloads,
likes: level.likes,
disliked: level.disliked,
length: level.length,
stars: level.stars,
orbs: level.orbs,
diamonds: level.diamonds,
featured: level.featured,
epic: level.epic,
gameVersion: level.gameVersion,
version: level.version,
copiedID: level.copiedID,
twoPlayer: level.twoPlayer,
customSong: customSong,
coins: level.coins,
verifiedCoins: level.verifiedCoins,
starsRequested: level.starsRequested,
objects: level.objects,
large: level.large,
creatorPoints: level.creatorPoints,
song: new Song({
name: level.songName,
author: level.songAuthor,
megabytes: parseInt(level.songSize.replace('MB', '')),
id: level.songID,
link: level.songLink
}),
});
}
exports.findProfile = findProfile;
exports.findLevel = findLevel;