forked from RedSparr0w/Discord-bot-pokeclicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regexMatches.js
314 lines (306 loc) · 12 KB
/
regexMatches.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
const { EmbedBuilder } = require('discord.js');
const { serverIcons } = require('./config.js');
const { addOrderedReactions, formatDateToString } = require('./helpers.js');
const { HOUR } = require('./helpers/constants.js');
const { modLog, mute } = require('./other/mod/functions.js');
module.exports = [
// Auto react to comments if 2+ lines start with an emoji
{
regex: {
test: (content) => {
const emoji_regex = /^((?:<:.+?:)\d+|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/;
const lines = content.split(/\r?\n/).map(line=>line.trim());
const answers = lines.filter(line=>emoji_regex.test(line));
return answers.length >= 2;
},
},
execute: (message, client) => {
const emoji_regex = /^((?:<:.+?:)\d+|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/;
const lines = message.content.split(/\r?\n/).map(line=>line.trim());
const answers = lines.filter(line=>emoji_regex.test(line));
const reactions = answers.map(answer=>answer.match(emoji_regex)[1]);
addOrderedReactions(message, reactions);
},
},
// soon™
{
regex: /(\b(wh?ens?)\b.+\b(released?|version|updated?|hisui|paldea)\b|\b(released?|version|updated?|hisui|paldea)\b.+\b(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('soon™');
},
},
// galar™
{
regex: /(\b(wh?ens?)\s+(galar)\b|\b(galar)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1666428660:F>™');
},
},
// alola™
{
regex: /(\b(wh?ens?)\s+(alola)\b|\b(alola)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1649832120:F>™');
},
},
// kalos™
{
regex: /(\b(wh?ens?)\s+(kalos)\b|\b(kalos)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1617523860:F>™');
},
},
// unova™
{
regex: /(\b(wh?ens?)\s+(unova)\b|\b(unova)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1608721020:F>™');
},
},
// sinnoh™
{
regex: /(\b(wh?ens?)\s+(sinnoh)\b|\b(sinnoh)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1598607060:F>™');
},
},
// hoenn™
{
regex: /(\b(wh?ens?)\s+(hoenn)\b|\b(hoenn)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1593508320:F>™');
},
},
// johto™/kanto™
{
regex: /(\b(wh?ens?)\s+(johto|kanto)\b|\b(johto|kanto)\s+(wh?ens?)\b)/i,
execute: (message, client) => {
message.channel.send('<t:1578833220:F>™');
},
},
// cats > dogs
{
regex: /\b(legendary|roaming)\b.+\b(dogs?)\b/i,
execute: (message, client) => {
message.react('🐱');
},
},
// kabuto
{
regex: /\b(kabuto)\b/i,
execute: (message, client) => {
if (serverIcons?.kabuto) {
message.react(serverIcons.kabuto.match(/:(\d+)>/)[1]);
}
},
},
// shuckle
{
regex: /\b(shuckle)\b/i,
execute: (message, client) => {
if (serverIcons?.shuckle) {
message.react(serverIcons.shuckle.match(/:(\d+)>/)[1]);
}
},
},
// pants
{
regex: /\b(infin(ite|eat).wealth)\b/i,
execute: (message, client) => {
message.react('👖');
},
},
// FAQ
{
regex: /\b(how|where)\b.+\b(catch|find|get|evolve|buy)\b/i,
execute: (message, client) => {
// If they have been a member longer than a week, assume they know about the #faq & #bot-commands
const now = new Date();
now.setDate(now.getDate() - 7);
if (message.member && message.member.joinedTimestamp <= now) return;
// New member
const description = [];
// #faq
const faq = message.guild ? message.guild.channels.cache.find(channel => channel.name == 'faq') || '#faq' : '#faq';
if (faq) description.push(`You might be able to find the answer you are looking for in the ${faq}.`);
// #bot-commands
const botCommands = message.guild ? message.guild.channels.cache.find(channel => channel.name == 'bot-commands') || '#bot-commands' : '#bot-commands';
if (botCommands) description.push(`There may be a command available in ${botCommands}.`);
// companion
description.push('The [PokéClicker Companion](https://companion.pokeclicker.com/) has some useful tools.');
// wiki
description.push('The [PokéClicker Wiki](https://wiki.pokeclicker.com/) also contains a lot of valuable information.');
// Create the embed
const embed = new EmbedBuilder().setDescription(description.join('\n')).setColor('Random');
message.reply({embeds: [embed]});
},
},
// Remove discord invite links
{
regex: /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li)|discordapp\.\w{1,3}\/invite)\/.+[a-z]/i,
execute: (message, client) => {
modLog(
message.member.guild,
`**Mod:** ${message.member.guild.members.me.toString()}
**User:** ${message.member.toString()} (${message.member.id})
**Action:** _Deleted message_
**Reason:** _Invite link_
**Channel:** ${message.channel.name}
**Message Content:**
\`\`\`\n${message.content.replace(/```/g, '``')}\n\`\`\``.substring(0, 4000)
);
message.delete().catch(e => {});
},
},
// Try remove some of the fake free nitro stuff
{
regex: /(https?:\/\/)?(www\.)?(([a-c]|[e-z])iscord|d[a-z]iscord|d([a-h]|[j-z])scord|di[a-z]scord|di([a-r]|[t-z])cord|dis[a-z]cord|dis([a-b]|[d-z])ord|disc[a-z]ord|disc([a-n]|[p-z])rd|disco[a-z]rd|disco([a-q]|[s-z])d|discor[a-z]d|discor([a-c]|[e-z])|discord[a-z])[\w-]+\.\w{1,10}\//i,
execute: async (message, client) => {
if (/(https?:\/\/)?(www\.)?(discord(status|app|cdn)?\.\w{2,3})\//i.test(message.content)) {
return;
}
let time = 2 * HOUR;
time = await mute(message.member, time);
modLog(
message.member.guild,
`**Mod:** ${message.member.guild.members.me.toString()}
**User:** ${message.member.toString()} (${message.member.id})
**Action:** _Deleted message, Muted_
**Reason:** _Fake Discord link_
**Duration:** _${formatDateToString(time)}_
**Channel:** ${message.channel.name}
**Message Content:**
\`\`\`\n${message.content.replace(/```/g, '``')}\n\`\`\``.substring(0, 4000)
);
message.delete().catch(e => {});
},
},
// Remove @everyone tags
{
regex: /@(everyone)/i,
execute: async (message, client) => {
let time = 2 * HOUR;
time = await mute(message.member, time);
modLog(
message.member.guild,
`**Mod:** ${message.member.guild.members.me.toString()}
**User:** ${message.member.toString()} (${message.member.id})
**Action:** _Muted_
**Reason:** _Tagging \\@everyone_
**Duration:** _${formatDateToString(time)}_
**Channel:** ${message.channel.name}
**Message Link:** _[Here](${message.url})_
**Message Content:**
\`\`\`\n${message.content.replace(/```/g, '``')}\n\`\`\``.substring(0, 4000)
);
const embedDescription = `Please do not attempt to tag \\@everyone\n\nYou will be unmuted in ${formatDateToString(time)}.`;
const embed = new EmbedBuilder().setColor('#e74c3c').setDescription(embedDescription);
message.reply({ embeds: [embed] });
message.delete().catch(e => {});
},
},
// Try remove some of the fake free nitro stuff
{
regex: /https?:\/\/dis.*(\.gift\/|\/nitro)/i,
execute: async (message, client) => {
let time = 2 * HOUR;
time = await mute(message.member, time);
modLog(
message.member.guild,
`**Mod:** ${message.member.guild.members.me.toString()}
**User:** ${message.member.toString()} (${message.member.id})
**Action:** _Deleted message, Muted_
**Reason:** _Nitro scam link_
**Duration:** _${formatDateToString(time)}_
**Channel:** ${message.channel.name}
**Message Link:** _[Here](${message.url})_
**Message Content:**
\`\`\`\n${message.content.replace(/```/g, '``')}\n\`\`\``.substring(0, 4000)
);
message.delete().catch(e => {});
},
},
{
regex: /\.github\.io\/pokeclicker/i,
execute: (message, client) => {
// Add an exception for companion app
if (message.content.includes('cypherx.github.io/pokeclicker-companion')) {
return;
}
modLog(
message.member.guild,
`**Mod:** ${message.member.guild.members.me.toString()}
**User:** ${message.member.toString()} (${message.member.id})
**Action:** _Deleted message_
**Reason:** _Github.io link_
**Channel:** ${message.channel.name}
**Message Link:** _[Here](${message.url})_
**Message Content:**
\`\`\`\n${message.content.replace(/```/g, '``')}\n\`\`\``.substring(0, 4000)
);
message.delete().catch(e => {});
},
},
{
// Telegram links
regex: /t\.me\//i,
execute: (message, client) => {
modLog(
message.member.guild,
`**Mod:** ${message.member.guild.members.me.toString()}
**User:** ${message.member.toString()} (${message.member.id})
**Action:** _Deleted message_
**Reason:** _Telegram link_
**Channel:** ${message.channel.name}
**Message Link:** _[Here](${message.url})_
**Message Content:**
\`\`\`\n${message.content.replace(/```/g, '``')}\n\`\`\``.substring(0, 4000)
);
message.delete().catch(e => {});
},
},
{
// Figure out a better way to test for the bots own ID/Role
regex: /(<@!?733927271726841887>|<@&751709977827082260>)/,
execute: (message, client) => {
if (/\b(Hello|Hi|Hey|Sup)\b/i.test(message.content)) {
const phrases = [
'Hello',
'Hey',
'👋',
];
message.reply(phrases[Math.floor(Math.random() * phrases.length)]);
} else if (/(thanks|ty|thank\s*you)/i.test(message.content)) {
const phrases = [
'No problem!',
'You\'re welcome!',
'You are welcome!',
'Anytime!',
'️️❤️',
'<:heartscale:761861364876574740>',
'No no, Thank you!',
];
message.reply(phrases[Math.floor(Math.random() * phrases.length)]);
} else {
const phrases = [
'Why have you summoned me?',
'What do you need?',
'Here to help..',
];
message.reply(phrases[Math.floor(Math.random() * phrases.length)]);
}
},
},
{
// If contains some Git Hub keywords
regex: /\b(prs?|git(\s?hub)?|pull(\s?request)?s?|gh|issues?|commits?|merges?)\b/i,
execute: (message, client) => {
const PRs = message.content.match(/#(\d{1,5})\b/g);
// Ensure it matches at least once
if (!PRs || !PRs.length) {
return;
}
message.reply(`Linked PRs detected: ${PRs.map(pr => `[${pr}](https://github.com/pokeclicker/pokeclicker/pull/${pr.slice(1)})`).join(' ')}`);
},
},
];