Skip to content

Commit 3b70723

Browse files
committed
Merge branch 'main' into springify
2 parents 21b9198 + 5234032 commit 3b70723

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

src/main/java/net/javadiscord/javabot/systems/help/HelpChannelUpdater.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ private void updateHelpOverview() {
395395
helpConfig.getHelpOverviewMessageIds().put(channelId, m.getIdLong());
396396
botConfig.flush();
397397
log.info("Successfully created new Help Overview Message in '{}' on message with id '{}'", channelId, m.getId());
398+
ExceptionLogger.capture(err);
399+
botConfig.get(m.getGuild()).getModerationConfig().getLogChannel().sendMessage("Sent new help-overview message (Check sentry for cause!)").queue();
398400
})
399401
);
400402
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package net.javadiscord.javabot.systems.help.commands;
2+
3+
import java.util.concurrent.ScheduledExecutorService;
4+
5+
import net.dv8tion.jda.api.interactions.commands.OptionType;
6+
import net.dv8tion.jda.api.interactions.commands.build.Commands;
7+
import net.javadiscord.javabot.data.config.BotConfig;
8+
import net.javadiscord.javabot.data.h2db.DbActions;
9+
10+
/**
11+
* A simple command that can be used inside reserved help channels to immediately unreserve them,
12+
* instead of waiting for a timeout.
13+
* An alias to /unreserve
14+
*/
15+
public class CloseCommand extends UnreserveCommand {
16+
17+
/**
18+
* The constructor of this class, which sets the corresponding
19+
* {@link net.dv8tion.jda.api.interactions.commands.build.SlashCommandData}.
20+
* @param asyncPool The thread pool for asynchronous operations
21+
* @param botConfig The main configuration of the bot
22+
* @param dbActions A utility object providing various operations on the main database
23+
*/
24+
public CloseCommand(BotConfig botConfig, ScheduledExecutorService asyncPool, DbActions dbActions) {
25+
super(botConfig, asyncPool, dbActions);
26+
setSlashCommandData(
27+
Commands.slash("close", "Unreserves this help channel so that others can use it.")
28+
.setGuildOnly(true).addOption(OptionType.STRING, "reason",
29+
"The reason why you're unreserving this channel", false));
30+
}
31+
}

src/main/java/net/javadiscord/javabot/systems/help/commands/UnreserveCommand.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import java.util.concurrent.ScheduledExecutorService;
44

5-
import javax.sql.DataSource;
6-
75
import com.dynxsty.dih4jda.interactions.commands.SlashCommand;
86
import net.dv8tion.jda.api.entities.TextChannel;
97
import net.dv8tion.jda.api.entities.User;
@@ -23,7 +21,6 @@
2321
*/
2422
public class UnreserveCommand extends SlashCommand {
2523
private final BotConfig botConfig;
26-
private final DataSource dataSource;
2724
private final ScheduledExecutorService asyncPool;
2825
private final DbActions dbActions;
2926

@@ -35,7 +32,6 @@ public class UnreserveCommand extends SlashCommand {
3532
*/
3633
public UnreserveCommand(BotConfig botConfig, ScheduledExecutorService asyncPool, DbActions dbActions) {
3734
this.botConfig = botConfig;
38-
this.dataSource = dbActions.getDataSource();
3935
this.asyncPool = asyncPool;
4036
this.dbActions = dbActions;
4137
setSlashCommandData(Commands.slash("unreserve", "Unreserves this help channel so that others can use it.")

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,12 @@ public boolean hasSuspiciousLink(@NotNull Message message) {
238238
public boolean hasAdvertisingLink(@NotNull Message message) {
239239
// Advertising
240240
Matcher matcher = INVITE_URL.matcher(cleanString(message.getContentRaw()));
241-
if (matcher.find()) {
242-
return botConfig.get(message.getGuild()).getModerationConfig().getAutomodInviteExcludes().stream().noneMatch(message.getContentRaw()::contains);
241+
int start = 0;
242+
while (matcher.find(start)) {
243+
if (botConfig.get(message.getGuild()).getModerationConfig().getAutomodInviteExcludes().stream().noneMatch(matcher.group()::contains)) {
244+
return true;
245+
}
246+
start = matcher.start() + 1;
243247
}
244248
return false;
245249
}

0 commit comments

Comments
 (0)