forked from AlexzanderFlores/Worn-Off-Keys-Discord-Js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanti-ad.js
32 lines (27 loc) · 768 Bytes
/
anti-ad.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
module.exports = (client) => {
const isInvite = async (guild, code) => {
return await new Promise((resolve) => {
guild.fetchInvites().then((invites) => {
for (const invite of invites) {
if (code === invite[0]) {
resolve(true)
return
}
}
resolve(false)
})
})
}
client.on('message', async (message) => {
const { guild, member, content } = message
// discord.gg/23RAN4
const code = content.split('discord.gg/')[1]
console.log('CODE:', code)
if (content.includes('discord.gg/')) {
const isOurInvite = await isInvite(guild, code)
if (!isOurInvite) {
// we know that they are advertising an outside discord server
}
}
})
}