-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (27 loc) · 869 Bytes
/
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
const config = require('./secret.json');
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
const isGonk = (message) => {
let i = 0, j = 0;
const gonk = 'gonk';
while (i < gonk.length && j < message.length) {
if (gonk[i] === message[j]) i++;
j++;
}
return i === gonk.length;
};
const removeUrl = (string) => `${string}`.replace(/http\/?[^(\s|$)]+(\s|$)/g, '');
const formatMessage = (message) => {
message = message.toLowerCase();
return removeUrl(message);
};
client.on('message', (message) => {
const formattedMessage = formatMessage(message.content);
if (isGonk(formattedMessage) && message.author.id !== client.user.id) {
message.channel.send('GONK!');
}
});
client.login(config.token);