-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
70 lines (51 loc) · 1.87 KB
/
index.js
File metadata and controls
70 lines (51 loc) · 1.87 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
const { Client } = require('discord.js-selfbot-v13');
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const fs = require('fs');
const accounts = JSON.parse(fs.readFileSync('accounts.json', 'utf8')).accounts;
const accountIds = () => clients.map(client => client.user.id);
const clients = [];
async function Add(id, channel, token) {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.open("PUT", `https://canary.discord.com/api/v9/channels/${channel}/recipients/${id}`);
xhr.setRequestHeader("Authorization", token);
xhr.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/91.0.4472.124 Safari/537.36");
xhr.onload = function () {
if (xhr.status === 204) {
resolve();
} else {
reject(new Error(`Already added or failed: ${xhr.status}`));
}
};
xhr.send();
}).catch(error => {
console.error(`Error in Add function: ${error.message}`);
});
}
function createClient(token) {
const client = new Client({
checkUpdate: false,
});
client.on('ready', () => {
console.log(`Client ready: ${client.user.username} [${client.user.id}]`);
});
client.on('channelRecipientRemove', async (channel, member) => {
const memberId = member.id;
if (accountIds().includes(memberId)) {
const startTime = Date.now();
// Add the account back to the group chat
await Add(memberId, channel.id, token);
const endTime = Date.now();
const duration = endTime - startTime;
console.log(`User added after removal. Time taken: ${duration}ms`);
}
});
client.login(token);
return client;
}
for (const account of accounts) {
const { token } = account;
const client = createClient(token);
clients.push(client);
}
console.log("* ReboundGuardian: https://github.com/fknMega")