This repository was archived by the owner on Mar 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFriends-List.js
48 lines (40 loc) · 1.46 KB
/
Friends-List.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
const fs = require('fs')
const request = require('../utils/request')
const debug = require('../config').debug
const constants = require('../utils/constants')
var user, id
var friends = ""
var json = []
var max = 0
const setMax = (list) => {
for (var e in list) {
user = list[e].user
user = `${user.username}#${user.discriminator}`
max < user.length ? max = user.length : max
}
}
module.exports = async (token) => {
if (!constants.tokenRe.test(token) && !constants.MFAtokenRe.test(token)) {
console.log("\nDiscord Exporters - INVALID TOKEN PROVIDED")
} else {
var list = await request(token, "/users/@me/relationships", "GET")
if (debug) {
list.success ? console.log(`Relationships: ${list.success}`) : console.log(`Relationships: ${list.success} => ${JSON.stringify(list.data)}`)
}
list = list.data
setMax(list)
for (var e in list) {
user = list[e].user
id = user.id
user = `${user.username}#${user.discriminator}`
friends += `${user}${" ".repeat((max - user.length) + 1)}: ${id}\n`
json.push({
username: user,
id: id
})
}
fs.writeFileSync("./results/friends_list.txt", friends)
fs.writeFileSync("./results/friends_list.json", JSON.stringify(json, null, 1))
console.log("FRIENDS_LIST exported in 'results' folder!")
}
}