-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (31 loc) · 1.17 KB
/
index.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
require('dotenv').config()
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("message", async (message) => {
if (message.author.bot) return;
const regex = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|club)|discordapp\.com\/invite|discord\.com\/invite)\/.+[a-z]/gi;
const allowedInvites = process.env.INVITES.split(',');
let content = message.content;
allowedInvites.forEach((invite) => {
content = content.replace(invite, '');
});
if (!message.member.hasPermission('MANAGE_GUILD')) {
if (regex.exec(content)) {
await message.delete();
const alertChannel = client.channels.cache.get(process.env.ALERT_CHAN_ID);
alertChannel
.send(`**<@${message.author.id}> sent an invite in <#${message.channel.id}>**\nMessage content:`);
alertChannel.send(message.content);
try {
await message.author
.send(`Don't send invite links on The Programmer's Hangout. https://tenor.com/t42s.gif`)
} catch (exception) {
console.log(exception);
}
}
}
});
client.login(process.env.TOKEN);