-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgets.js
57 lines (56 loc) · 2.01 KB
/
gets.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 useGets = async (res, req, guild, user) => {
try {
const member = user
if (member) {
const pres = await member.presence;
const user = pres.user;
let activities;
let conditions = {};
if (pres.activities.length === 0) {
activities = null
} else {
activities = pres.activities;
}
if (pres.clientStatus) {
const status = pres.clientStatus;
conditions = {
web: status.web === undefined ? "offline" : status.web,
desktop: status.desktop === undefined ? "offline" : status.desktop,
mobile: status.mobile === undefined ? "offline" : status.mobile,
}
}
res.status(200).json({
id: pres.userId,
status: pres.status,
tag: user.tag,
created_at: user.createdAt,
created_timestamp: user.createdTimestamp,
discriminator: user.discriminator,
bot: user.bot,
activities: activities,
public_flags: user.flags,
avatars: {
id: user.avatar,
url: user.avatarURL(),
default: user.defaultAvatarURL,
},
names: {
name: user.username,
global: user.globalName,
display: user.displayName,
},
banners: {
id: user.banner,
url: user.bannerURL(),
},
conditions: conditions,
api_status: "success"
});
} else {
res.status(404).json({ error: 'User not found', api_status: "failed" });
}
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', api_status: "failed" });
}
}
module.exports = { useGets }