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
|
const axios = require('axios');
const apiVersion = "v10";
const app = require('../../app.json');
function sleep(ms) {
return new Promise((res) => {
setTimeout(res, ms);
});
}
(async () => {
let user = process.argv[2];
try {
let data = (await axios.get(`https://discord.com/api/${apiVersion}/users/${user}`, {
headers: {
Authorization: `Bot ${app.discord.token}`
}
})).data;
let obj = {
error: null,
avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/discord.png",
name: user,
description: "Discord",
link: null,
copy: [
{
title: "Copy full username",
text: data['discriminator'] === "0" ? data['username'] : `${data['username']}#${data['discriminator']}`
},
{
title: "Copy mention",
text: `<@${user}>`
},
{
title: "Copy ID",
text: `${user}`
},
data['avatar'] ? {
title: "Copy avatar URL",
text: `https://cdn.discordapp.com/avatars/${user}/${data['avatar']}.png`
} : null
]
}
if (data['display_name'] || data['global_name']) {
obj.description = data['discriminator'] === "0" ? data['username'] : `${data['username']}#${data['discriminator']}`;
} else {
obj.description = "#" + data['discriminator'];
}
if (data['avatar']) {
obj.avatar = `https://cdn.discordapp.com/avatars/${user}/${data['avatar']}.png`;
}
obj.name = data['display_name'] ?? data['global_name'] ?? data['username'] ?? data['id'];
console.log(JSON.stringify(obj, null, 2));
} catch (e) {
console.log(JSON.stringify({
error: e,
avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/discord.png",
name: user,
description: "Discord",
link: null,
copy: []
}, null, 2));
}
})();
|