-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdavet
42 lines (29 loc) · 1.02 KB
/
davet
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
const invites = {};
const wait = require('util').promisify(setTimeout);
client.on('ready', () => {
wait(1000);
client.guilds.forEach(g => {
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
});
client.on('guildMemberAdd', member => {
try{
if (db.has(`davetChannel_${member.guild.id}`) === true) {
member.guild.fetchInvites().then(guildInvites => {
if (member.user.bot) return
const ei = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
const inviter = client.users.get(invite.inviter.id);
const kanal = member.guild.channels.get(db.fetch(`davetChannel_${member.guild.id}`));
kanal.send(`\`${member.user.tag}\` adlı kullanıcı \`${inviter.tag}\` adlı kullanıcının ${invite.code} linkine sahip daveti ile sunucuya katıldı! (Kullanıcı ${invite.uses} kişi davet etmiş!)`);
});
} else {
return
}
} catch(err) {
return
}
});