-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
91 lines (84 loc) · 2.85 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
let invites = {};
async function inviteCounter(client) {
//bot açılınca bütün davetleri oku
client.on('ready', async () => {
setTimeout(() => {
client.guilds.cache.forEach(g => {
g.invites.fetch().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
}, 2000)
});
//yeni davet oluşturunca bütün davetleri oku
client.on("inviteCreate", (invite) => {
setTimeout(() => {
client.guilds.cache.forEach(g => {
g.invites.fetch().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
}, 2000)
});
//davet silinince bütün davetleri oku
client.on("inviteDelete", (invite) => {
setTimeout(() => {
client.guilds.cache.forEach(g => {
g.invites.fetch().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
}, 2000)
});
//bot yeni sunucuya alındığında bütün davetleri oku
client.on("guildCreate", (guild) => {
setTimeout(() => {
client.guilds.cache.forEach(g => {
g.invites.fetch().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
}, 2000)
});
//sunucuya üye gelince tetiklen
client.on('guildMemberAdd', member => {
try {
member.guild.invites.fetch().then(async guildInvites => {
const inv = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
if (!inv) return;
await member.guild.invites.fetch().catch(() => undefined);
const invite = guildInvites.find(i => {
const a = inv.get(i.code);
if (!a) return;
return a
});
if (!invite) return;
const inviter = client.users.cache.get(invite.inviter.id);
const guild = member.guild;
client.emit("memberJoin", member, invite, inviter, guild)
});
} catch (e) {}
});
//sunucudan üye gidince tetiklen
client.on('guildMemberRemove', member => {
try {
member.guild.invites.fetch().then(async guildInvites => {
const inv = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
if (!inv) return;
await member.guild.invites.fetch().catch(() => undefined);
const invite = guildInvites.find(i => {
const a = inv.get(i.code);
if (!a) return;
return a
});
if (!invite) return;
const inviter = client.users.cache.get(invite.inviter.id);
const guild = member.guild;
client.emit("memberLeave", member, invite, inviter, guild)
});
} catch (e) {}
});
};
exports.inviteCounter = inviteCounter;