Skip to content

Commit cb1d854

Browse files
committed
Detect url encoded invites
1 parent 04b7e0f commit cb1d854

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/automod/AutoModManager.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,25 @@ export class AutoModManager {
270270
return await this.#deleteAndWarn(message, 'Sending invite links', 'Invites are not allowed here!');
271271
}
272272

273+
/**
274+
* Check if the message includes an invite link
275+
* @param {string} string the message content
276+
* @returns {boolean} does the string include an invite link
277+
*/
273278
includesInvite(string) {
274-
return ['discord.gg', 'discord.com/invite', 'discordapp.com/invite', 'invite.gg', 'discord.me', 'top.gg/servers', 'dsc.gg']
275-
.some(url => string.match(new RegExp(url + '/\\w+')));
279+
for (let part of string.split(/(\s|:\/\/)/)) {
280+
try {
281+
part = decodeURI(part);
282+
} catch { /* ignored */ }
283+
284+
for (let url of ['discord.gg', 'discord.com/invite', 'discordapp.com/invite', 'invite.gg', 'discord.me', 'top.gg/servers', 'dsc.gg']) {
285+
if (part.match(new RegExp(url + '/\\w+'))) {
286+
return true;
287+
}
288+
}
289+
}
290+
291+
return false;
276292
}
277293

278294
/**

0 commit comments

Comments
 (0)