Skip to content

Commit 93d1d34

Browse files
authored
Merge pull request #358 from danthe1st/fix-invite-automod
fix automod for multiple invites in single message
2 parents 619c748 + bc4bdee commit 93d1d34

File tree

1 file changed

+6
-2
lines changed
  • src/main/java/net/javadiscord/javabot/systems/moderation

1 file changed

+6
-2
lines changed

src/main/java/net/javadiscord/javabot/systems/moderation/AutoMod.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,12 @@ public boolean hasSuspiciousLink(@NotNull Message message) {
227227
public boolean hasAdvertisingLink(@NotNull Message message) {
228228
// Advertising
229229
Matcher matcher = INVITE_URL.matcher(cleanString(message.getContentRaw()));
230-
if (matcher.find()) {
231-
return Bot.getConfig().get(message.getGuild()).getModerationConfig().getAutomodInviteExcludes().stream().noneMatch(message.getContentRaw()::contains);
230+
int start = 0;
231+
while (matcher.find(start)) {
232+
if (Bot.getConfig().get(message.getGuild()).getModerationConfig().getAutomodInviteExcludes().stream().noneMatch(matcher.group()::contains)) {
233+
return true;
234+
}
235+
start = matcher.start() + 1;
232236
}
233237
return false;
234238
}

0 commit comments

Comments
 (0)