-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
95 lines (82 loc) · 1.92 KB
/
main.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
92
93
94
95
require('dotenv').config();
const { Client, Intents } = require('discord.js');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_BANS,
Intents.FLAGS.GUILD_MESSAGES,
],
});
// ~~ Startup ~~
client.login(process.env.TOKEN).then();
const guilds = {};
const lastSize = {};
const timeBetweenJoin = 1000;
const amountOfMembersToJoin = 10;
try {
for (let i = 0; i < process.stdout.getWindowSize()[1]; i++) {
console.log('\r\n');
}
} catch (_) {}
// ~~ Client Events ~~
client.on('error', (err) => {
console.log(err);
});
client.on('warn', (info) => {
console.log(info);
});
client.on('disconnect', () => {
console.log('Disconnected from Websocket');
});
client.on('reconnecting', () => {
console.log('Reconnecting to Websocket');
});
client.once('ready', () => {
console.log('Finished Booting');
});
client.on('guildMemberAdd', (member) => {
try {
guilds[member.guild.id].size;
} catch {
guilds[member.guild.id] = new Set();
}
guilds[member.guild.id].add(member);
lastSize[member.id] = guilds[member.guild.id].size;
setTimeout(() => {
if (guilds[member.guild.id].size !== lastSize[member.id]) {
delete lastSize[member.id];
return;
}
delete lastSize[member.id];
if (guilds[member.guild.id].size <= amountOfMembersToJoin - 1) {
delete guilds[member.guild.id];
return;
}
guilds[member.guild.id].forEach((m) => {
try {
m.ban({ reason: 'Yagi | Raid erkannt' })
.then(() => {
try {
member.guild.systemChannel.messages
.fetch({
limit: 100,
force: true,
cache: true,
})
.then((messages) => {
member.guild.systemChannel.bulkDelete(
messages.filter(
(msg) => msg.author.id === m.id
)
);
})
.catch();
} catch {}
})
.catch();
} catch {}
});
delete guilds[member.guild.id];
}, timeBetweenJoin);
});