-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlookup-user.js
More file actions
71 lines (63 loc) · 3.24 KB
/
Copy pathlookup-user.js
File metadata and controls
71 lines (63 loc) · 3.24 KB
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
// Copyright (c) 2021-2022 BuiltByBit (Mick Capital Pty. Ltd.)
// MIT License (https://github.com/BuiltByBit/js-api-wrapper/blob/main/LICENSE)
const { Wrapper, Token, TokenType } = require("@builtbybit/api-wrapper");
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let token = new Token(TokenType.PRIVATE, "Find @ https://builtbybit.com/account/api");
let wrapper = new Wrapper();
async function main() {
await wrapper.init(token);
rl.question("Lookup by (u)sername or by (i)d? ", (answer) => {
let userObj;
switch (answer.toLowerCase()) {
case "u":
try {
rl.question("What is the username of the user you'd like to lookup? ", async (username) => {
userObj = await wrapper.members().fetchByUsername(username).catch(e => { console.error(e); });
let memberId = userObj.member_id;
let joinDate = userObj.join_date;
let lastActivityDate = userObj.last_activity_date;
let banned = userObj.banned;
let suspended = userObj.suspended;
let restricted = userObj.restricted;
let disabled = userObj.disabled;
let postCount = userObj.post_count;
// eslint-disable-next-line max-len
let message = `${username}'s Statistics:\nMember Id: ${memberId}\nJoin Date: ${new Date(joinDate * 1000)}\nLast Activity: ${new Date(lastActivityDate * 1000)}\nBanned: ${banned}\nSuspended: ${suspended}\nRestricted: ${restricted}\nDisabled: ${disabled}\nPost Count: ${postCount}`;
console.log(message);
rl.close();
});
} catch (error) {
console.log("Error: " + error);
}
break;
case "i":
try {
rl.question("What is the ID of the user you'd like to lookup? ", async (userId) => {
let userObj = await wrapper.members().fetch(userId).catch(e => { console.log(e); });
let username = userObj.username;
let joinDate = userObj.join_date;
let lastActivityDate = userObj.last_activity_date;
let banned = userObj.banned;
let suspended = userObj.suspended;
let restricted = userObj.restricted;
let disabled = userObj.disabled;
let postCount = userObj.post_count;
// eslint-disable-next-line max-len
let message = `${userId}'s Statistics:\nUsername: ${username}\nJoin Date: ${new Date(joinDate * 1000)}\nLast Activity: ${new Date(lastActivityDate * 1000)}\nBanned: ${banned}\nSuspended: ${suspended}\nRestricted: ${restricted}\nDisabled: ${disabled}\nPost Count: ${postCount}`;
console.log(message);
rl.close();
});
} catch (error) {
console.log("ERROR: " + error);
}
break;
default:
console.log("Invalid Answer");
}
});
}
main().catch(error => console.error("ERROR: " + error));