-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (49 loc) · 1.53 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
const fetch = require('node-fetch');
class wlsApiJs {
/**
* Get User Data
* @param {String} name WLs name of the User
*/
async RegByName(name) {
if (name.length === 0) throw new TypeError("No Name spacified");
if (typeof name !== 'string') throw new TypeError('User Name Should be String');
return fetch(`https://api.wls.gg/users/name/${name}`, {
method: 'get',
}).then(res => res.json()).then(async json => {
return await json;
}).catch(async error => {
throw new Error(error);
});
}
/**
* Get User Data
* @param {String} id Discord id of the User
*/
async RegByDisId(id) {
if (id === undefined) throw new TypeError('No DiscordId spacified');
if (typeof id !== 'string') throw new TypeError('User Discord Id Should be String');
return fetch(`https://api.wls.gg/users/connection/discord/${id}`, {
method: 'get',
}).then(res => res.json()).then(async json => {
return await json;
}).catch(async error => {
throw new Error(error);
});
}
/**
* Get Room data by id
* @param {String} id wls room id
*/
async GetRoom(id) {
if (id === undefined) throw new TypeError('No Room ID spacified');
if (typeof id !== 'string') throw new TypeError('Room ID Should be String');
return fetch(`https://api.wls.gg/events/${id}`, {
method: 'get',
}).then(res => res.json()).then(async json => {
return await json;
}).catch(async error => {
throw new Error(error);
});
}
}
module.exports = wlsApiJs