-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremess.js
57 lines (48 loc) · 2.04 KB
/
premess.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
import * as socketIo from "socket.io-client"
import { askForForm } from "./src/prompt-helper.js"
import { startMessing } from "./src/mess.js"
import { isIPv6 } from "net"
import colors from "ansi-colors"
(async () => {
try {
let hostAddress = [
{
name: "address",
message: "Address",
initial: "127.0.0.1",
value: "127.0.0.1"
},
{
name: "port",
message: "Port",
initial: "3020",
value: "3020"
}
]
await askForForm("Enter target address", hostAddress);
let host = isIPv6(hostAddress[0].value) ? `[${hostAddress[0].value}]` : hostAddress[0].value;
let port = hostAddress[1].value;
let socket = socketIo.connect(`http://${host}:${port}`, {
transports: ["websocket"],
timestampRequests: true,
reconnectionAttempts: 3
});
let connected = false;
socket.on("connect_error", () => {
console.warn(colors.dim("Could not connect to host"));
});
socket.on("disconnect", () => {
console.log(colors.bold("Disconnected"));
process.exit(0);
});
socket.on("discordUser", (data) => {
if (!connected) {
console.log(colors.blueBright(`────────────────────────────────\nDiscord ID: ${data.id}\nDiscord username: ${data.username}#${data.discriminator}\nProfile Picture: https://cdn.discordapp.com/avatars/${data.id}/${data.avatar}.png?size=4096\nPremium: ${data.premium_type == 0 ? "No" : data.premium_type == 1 ? "Nitro Classic" : "Nitro"}\n────────────────────────────────`));
console.log(colors.bold("Connected to PreMiD"));
startMessing(socket);
connected = true;
}
});
socket.open();
} catch {}
})();