-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
42 lines (37 loc) · 764 Bytes
/
api.js
File metadata and controls
42 lines (37 loc) · 764 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
30
31
32
33
34
35
36
37
38
39
40
41
42
const axios = require('axios');
const { api_token, token } = require('./config.json');
async function search(username) {
try {
res = await axios.get(`https://api.namedc.org/search?query=${username}`, {
headers: {
"Authorization": `Bearer ${api_token}`
}
});
if (res.status == 200) {
return res.data;
} else {
return err.response.status;
}
} catch (err) {
return err.response.status;
}
}
//get user by id
async function getUser(id) {
try {
//send request to discord api
res = await axios.get(`https://discord.com/api/v9/users/${id}`, {
headers: {
"Authorization": `Bot ${token}`
}
});
//return data
return res.data;
} catch (err) {
return err.response.status;
}
}
module.exports = {
search,
getUser
};