-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
91 lines (78 loc) · 2.37 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const axios = require('axios');
const fs = require('fs');
const path = require('path');
const WebSocket = require('ws');
const config = require('./config.json');
const filepath = './tokens.txt';
function sort(filepath) {
const fileContent = fs.readFileSync(filepath, 'utf-8');
return fileContent.split('\n')
.map(line => line.trim())
.filter(line => line.length > 0)
.sort();
}
async function checkTokens(tokens) {
const validTokens = [];
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
try {
const response = await axios.get('https://discord.com/api/v10/users/@me', {
headers: {
Authorization: `${token}`
}
});
console.log(`Token ${i + 1} is valid:`);
validTokens.push(token);
} catch (error) {
if (error.response && error.response.status === 401) {
console.error(`Token ${i + 1} is invalid`);
} else {
console.error(`Error checking token ${i + 1}:`, error.message);
}
}
}
return validTokens;
}
function ws_joiner(token, username) {
const ws = new WebSocket('wss://gateway.discord.gg/?v=9&encoding=json');
const auth = {
op: 2,
d: {
token: token,
properties: {
$os: 'Linux',
$browser: 'Firefox',
$device: 'desktop'
}
}
};
const vc = {
op: 4,
d: {
guild_id: config.GUILD_ID,
channel_id: config.VC_CHANNEL,
self_mute: config.MUTED,
self_deaf: config.DEAFEN
}
};
ws.on('open', () => {
ws.send(JSON.stringify(auth));
ws.send(JSON.stringify(vc));
console.info(`\x1b[32mToken ${token} joined the voice channel successfully\x1b[0m`);
});
ws.on('error', console.error);
setTimeout(() => ws.close(), 300000);
}
async function main() {
const tokens = sort(filepath);
const validTokens = await checkTokens(tokens);
validTokens.forEach(token => {
ws_joiner(token);
});
setInterval(() => {
validTokens.forEach(token => {
ws_joiner(token);
});
}, 300000);
}
main();