createFeatures(JDA jda, Database database, Con
features.add(codeMessageHandler);
features.add(new CodeMessageAutoDetection(config, codeMessageHandler));
features.add(new CodeMessageManualDetection(codeMessageHandler));
+ features.add(new SlashCommandEducator());
// Event receivers
features.add(new RejoinModerationRoleListener(actionsStore, config));
- features.add(new OnGuildLeaveCloseThreadListener(database));
- features.add(new UserBannedDeleteRecentThreadsListener(database));
+ features.add(new GuildLeaveCloseThreadListener(config));
features.add(new LeftoverBookmarksListener(bookmarksSystem));
features.add(new HelpThreadCreatedListener(helpSystemHelper));
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/MessageContextCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/MessageContextCommand.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/MessageContextCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/MessageContextCommand.java
index 0d0e767340..2a499176fe 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/MessageContextCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/MessageContextCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
@@ -7,7 +7,7 @@
import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
import java.util.List;
@@ -31,7 +31,7 @@
* ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
*
- * Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
+ * Some example commands are available in {@link org.togetherjava.tjbot.features.basic}.
*/
public interface MessageContextCommand extends BotCommand {
/**
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/MessageReceiver.java b/application/src/main/java/org/togetherjava/tjbot/features/MessageReceiver.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/MessageReceiver.java
rename to application/src/main/java/org/togetherjava/tjbot/features/MessageReceiver.java
index 35843ead1c..c5b6358434 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/MessageReceiver.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/MessageReceiver.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/MessageReceiverAdapter.java b/application/src/main/java/org/togetherjava/tjbot/features/MessageReceiverAdapter.java
similarity index 88%
rename from application/src/main/java/org/togetherjava/tjbot/commands/MessageReceiverAdapter.java
rename to application/src/main/java/org/togetherjava/tjbot/features/MessageReceiverAdapter.java
index 6a8f1a5fa3..05280c97ab 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/MessageReceiverAdapter.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/MessageReceiverAdapter.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@@ -18,6 +18,13 @@ public abstract class MessageReceiverAdapter implements MessageReceiver {
private final Pattern channelNamePattern;
+ /**
+ * Creates an instance of a message receiver, listening to messages of all channels.
+ */
+ protected MessageReceiverAdapter() {
+ this(Pattern.compile(".*"));
+ }
+
/**
* Creates an instance of a message receiver with the given pattern.
*
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/Routine.java b/application/src/main/java/org/togetherjava/tjbot/features/Routine.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/Routine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/Routine.java
index 0b9456aa2b..b5d2f614af 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/Routine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/Routine.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.JDA;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/SlashCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/SlashCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/SlashCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/SlashCommand.java
index 0e89ee50c1..0fdb69f20a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/SlashCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/SlashCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -11,7 +11,7 @@
import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
import java.util.List;
@@ -37,7 +37,7 @@
* ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
*
- * Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
+ * Some example commands are available in {@link org.togetherjava.tjbot.features.basic}.
*/
public interface SlashCommand extends BotCommand {
/**
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/SlashCommandAdapter.java b/application/src/main/java/org/togetherjava/tjbot/features/SlashCommandAdapter.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/SlashCommandAdapter.java
rename to application/src/main/java/org/togetherjava/tjbot/features/SlashCommandAdapter.java
index 48a4caf4c6..43c5a01020 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/SlashCommandAdapter.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/SlashCommandAdapter.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -35,7 +35,7 @@
* IDs generated by {@link #generateComponentId(String...)}, which will automatically create IDs
* that are valid per {@link SlashCommand#onSlashCommand(SlashCommandInteractionEvent)}.
*
- * Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}. A minimal
+ * Some example commands are available in {@link org.togetherjava.tjbot.features.basic}. A minimal
* setup would consist of a class like
*
*
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/UserContextCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/UserContextCommand.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/UserContextCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/UserContextCommand.java
index 36a7aeb5cc..57aa3f7949 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/UserContextCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/UserContextCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
@@ -7,7 +7,7 @@
import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
import java.util.List;
@@ -32,7 +32,7 @@
* ({@link #onButtonClick(ButtonInteractionEvent, List)}) or menus
* ({@link #onSelectMenuSelection(SelectMenuInteractionEvent, List)}) have been triggered.
*
- * Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
+ * Some example commands are available in {@link org.togetherjava.tjbot.features.basic}.
*/
public interface UserContextCommand extends BotCommand {
/**
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/UserInteractionType.java b/application/src/main/java/org/togetherjava/tjbot/features/UserInteractionType.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/UserInteractionType.java
rename to application/src/main/java/org/togetherjava/tjbot/features/UserInteractionType.java
index 799852d7b2..5acfdf2beb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/UserInteractionType.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/UserInteractionType.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
/**
* Different types of user interactions.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/UserInteractor.java b/application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/UserInteractor.java
rename to application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java
index 7bae9e1036..6adaf1d0e7 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/UserInteractor.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java
@@ -1,13 +1,13 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
-import org.togetherjava.tjbot.commands.componentids.ComponentId;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
-import org.togetherjava.tjbot.commands.componentids.Lifespan;
+import org.togetherjava.tjbot.features.componentids.ComponentId;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.Lifespan;
import java.util.List;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/basic/PingCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/PingCommand.java
similarity index 82%
rename from application/src/main/java/org/togetherjava/tjbot/commands/basic/PingCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/basic/PingCommand.java
index 0b287c151c..c4dc10a7bc 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/basic/PingCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/PingCommand.java
@@ -1,9 +1,9 @@
-package org.togetherjava.tjbot.commands.basic;
+package org.togetherjava.tjbot.features.basic;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
/**
* Implementation of an example command to illustrate how to respond to a user.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/basic/RoleSelectCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/RoleSelectCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/basic/RoleSelectCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/basic/RoleSelectCommand.java
index a96ddef619..ae33bb7503 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/basic/RoleSelectCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/RoleSelectCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.basic;
+package org.togetherjava.tjbot.features.basic;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
@@ -17,9 +17,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.componentids.Lifespan;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.componentids.Lifespan;
import java.awt.*;
import java.util.*;
diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/SlashCommandEducator.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SlashCommandEducator.java
new file mode 100644
index 0000000000..a9d8056e1a
--- /dev/null
+++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SlashCommandEducator.java
@@ -0,0 +1,71 @@
+package org.togetherjava.tjbot.features.basic;
+
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.MessageEmbed;
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
+import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
+import net.dv8tion.jda.api.utils.FileUpload;
+
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
+import org.togetherjava.tjbot.features.help.HelpSystemHelper;
+
+import java.io.InputStream;
+import java.util.function.Predicate;
+import java.util.regex.Pattern;
+
+/**
+ * Listens to messages that are likely supposed to be message commands, such as {@code !foo} and
+ * then educates the user about using slash commands, such as {@code /foo} instead.
+ */
+public final class SlashCommandEducator extends MessageReceiverAdapter {
+ private static final String SLASH_COMMAND_POPUP_ADVICE_PATH = "slashCommandPopupAdvice.png";
+ private static final Predicate IS_MESSAGE_COMMAND = Pattern.compile("""
+ [.!?] #Start of message command
+ [a-zA-Z]{2,15} #Name of message command, e.g. 'close'
+ .* #Rest of the message
+ """, Pattern.COMMENTS).asMatchPredicate();
+
+ @Override
+ public void onMessageReceived(MessageReceivedEvent event) {
+ if (event.getAuthor().isBot() || event.isWebhookMessage()) {
+ return;
+ }
+
+ String content = event.getMessage().getContentRaw();
+ if (IS_MESSAGE_COMMAND.test(content)) {
+ sendAdvice(event.getMessage());
+ }
+ }
+
+ private void sendAdvice(Message message) {
+ String content =
+ """
+ Looks like you attempted to use a command? Please note that we only use **slash-commands** on this server 🙂
+
+ Try starting your message with a forward-slash `/` and Discord should open a popup showing you all available commands.
+ A command might then look like `/foo` 👍""";
+
+ createReply(message, content, SLASH_COMMAND_POPUP_ADVICE_PATH).queue();
+ }
+
+ private static MessageCreateAction createReply(Message messageToReplyTo, String content,
+ String imagePath) {
+ boolean useImage = true;
+ InputStream imageData = HelpSystemHelper.class.getResourceAsStream("/" + imagePath);
+ if (imageData == null) {
+ useImage = false;
+ }
+
+ MessageEmbed embed = new EmbedBuilder().setDescription(content)
+ .setImage(useImage ? "attachment://" + imagePath : null)
+ .build();
+
+ MessageCreateAction action = messageToReplyTo.replyEmbeds(embed);
+ if (useImage) {
+ action = action.addFiles(FileUpload.fromData(imageData, imagePath));
+ }
+
+ return action;
+ }
+}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/basic/SuggestionsUpDownVoter.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/basic/SuggestionsUpDownVoter.java
rename to application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java
index d2eccaef77..0a5add113b 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/basic/SuggestionsUpDownVoter.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.basic;
+package org.togetherjava.tjbot.features.basic;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
@@ -10,9 +10,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.SuggestionsConfig;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
import java.util.Optional;
import java.util.regex.Pattern;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/basic/VcActivityCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/VcActivityCommand.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/basic/VcActivityCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/basic/VcActivityCommand.java
index f66cb77d68..fec6573582 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/basic/VcActivityCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/VcActivityCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.basic;
+package org.togetherjava.tjbot.features.basic;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.GuildVoiceState;
@@ -16,8 +16,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/basic/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/package-info.java
similarity index 87%
rename from application/src/main/java/org/togetherjava/tjbot/commands/basic/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/basic/package-info.java
index 0c110ffc26..a41150eea2 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/basic/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/package-info.java
@@ -4,7 +4,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.basic;
+package org.togetherjava.tjbot.features.basic;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java
index 16dbbe34f8..d391ac299f 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.bookmarks;
+package org.togetherjava.tjbot.features.bookmarks;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
@@ -12,8 +12,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import java.util.List;
import java.util.Objects;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksListRemoveHandler.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksListRemoveHandler.java
rename to application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java
index e3ea0e4b2e..909b9b7f57 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksListRemoveHandler.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.bookmarks;
+package org.togetherjava.tjbot.features.bookmarks;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
@@ -15,8 +15,8 @@
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
import net.dv8tion.jda.api.interactions.components.selections.SelectOption;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.db.generated.tables.records.BookmarksRecord;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import java.awt.Color;
import java.util.*;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksSystem.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksSystem.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksSystem.java
rename to application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksSystem.java
index bed490dbe0..f7751e35e2 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/BookmarksSystem.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksSystem.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.bookmarks;
+package org.togetherjava.tjbot.features.bookmarks;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/LeftoverBookmarksCleanupRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/LeftoverBookmarksCleanupRoutine.java
similarity index 89%
rename from application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/LeftoverBookmarksCleanupRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/bookmarks/LeftoverBookmarksCleanupRoutine.java
index a680d84240..dab052aa67 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/LeftoverBookmarksCleanupRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/LeftoverBookmarksCleanupRoutine.java
@@ -1,8 +1,8 @@
-package org.togetherjava.tjbot.commands.bookmarks;
+package org.togetherjava.tjbot.features.bookmarks;
import net.dv8tion.jda.api.JDA;
-import org.togetherjava.tjbot.commands.Routine;
+import org.togetherjava.tjbot.features.Routine;
import java.util.concurrent.TimeUnit;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/LeftoverBookmarksListener.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/LeftoverBookmarksListener.java
similarity index 91%
rename from application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/LeftoverBookmarksListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/bookmarks/LeftoverBookmarksListener.java
index 5252f6ea07..a033bd188a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/LeftoverBookmarksListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/LeftoverBookmarksListener.java
@@ -1,10 +1,10 @@
-package org.togetherjava.tjbot.commands.bookmarks;
+package org.togetherjava.tjbot.features.bookmarks;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
-import org.togetherjava.tjbot.commands.EventReceiver;
+import org.togetherjava.tjbot.features.EventReceiver;
/**
* Initiates the bookmarks deletion period for a user when leaving the guild. When the user rejoins
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/package-info.java
similarity index 75%
rename from application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/bookmarks/package-info.java
index 8327cf37ab..dcf29870bb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/bookmarks/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/package-info.java
@@ -1,11 +1,11 @@
/**
* This package offers all functionality for maintaining bookmarks. For example commands that let
* users bookmark a help thread, such as
- * {@link org.togetherjava.tjbot.commands.bookmarks.BookmarksCommand}.
+ * {@link org.togetherjava.tjbot.features.bookmarks.BookmarksCommand}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.bookmarks;
+package org.togetherjava.tjbot.features.bookmarks;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeAction.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeAction.java
similarity index 84%
rename from application/src/main/java/org/togetherjava/tjbot/commands/code/CodeAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/code/CodeAction.java
index 8cec47141b..db58f319f3 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeAction.java
@@ -1,8 +1,8 @@
-package org.togetherjava.tjbot.commands.code;
+package org.togetherjava.tjbot.features.code;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.togetherjava.tjbot.commands.utils.CodeFence;
+import org.togetherjava.tjbot.features.utils.CodeFence;
/**
* Actions that can be executed on code, such as running it.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageAutoDetection.java
similarity index 91%
rename from application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java
rename to application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageAutoDetection.java
index 1a8cd42173..2a95879449 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageAutoDetection.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageAutoDetection.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.code;
+package org.togetherjava.tjbot.features.code;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.Role;
@@ -6,10 +6,10 @@
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
-import org.togetherjava.tjbot.commands.utils.CodeFence;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
+import org.togetherjava.tjbot.features.utils.CodeFence;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import java.util.List;
import java.util.Optional;
@@ -34,8 +34,6 @@ public final class CodeMessageAutoDetection extends MessageReceiverAdapter {
* @param codeMessageHandler to register detected code messages at for further handling
*/
public CodeMessageAutoDetection(Config config, CodeMessageHandler codeMessageHandler) {
- super(Pattern.compile(".*"));
-
this.codeMessageHandler = codeMessageHandler;
isHelpForumName =
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageHandler.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageHandler.java
rename to application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java
index 341c8ad351..21ddf289df 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageHandler.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.code;
+package org.togetherjava.tjbot.features.code;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -16,20 +16,19 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
-import org.togetherjava.tjbot.commands.UserInteractionType;
-import org.togetherjava.tjbot.commands.UserInteractor;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdInteractor;
-import org.togetherjava.tjbot.commands.utils.CodeFence;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
+import org.togetherjava.tjbot.features.UserInteractionType;
+import org.togetherjava.tjbot.features.UserInteractor;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor;
+import org.togetherjava.tjbot.features.utils.CodeFence;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import javax.annotation.Nullable;
import java.awt.Color;
import java.util.*;
import java.util.function.Function;
-import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -66,8 +65,6 @@ public final class CodeMessageHandler extends MessageReceiverAdapter implements
* Creates a new instance.
*/
public CodeMessageHandler() {
- super(Pattern.compile(".*"));
-
componentIdInteractor = new ComponentIdInteractor(getInteractionType(), getName());
List codeActions = List.of(new FormatCodeCommand());
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageManualDetection.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java
similarity index 83%
rename from application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageManualDetection.java
rename to application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java
index 3647002f53..3f7dcf6503 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/code/CodeMessageManualDetection.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java
@@ -1,11 +1,11 @@
-package org.togetherjava.tjbot.commands.code;
+package org.togetherjava.tjbot.features.code;
import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
-import org.togetherjava.tjbot.commands.BotCommandAdapter;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.MessageContextCommand;
+import org.togetherjava.tjbot.features.BotCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.MessageContextCommand;
/**
* Context command to allow users to select messages that contain code. They are then registered at
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/FormatCodeCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/code/FormatCodeCommand.java
similarity index 91%
rename from application/src/main/java/org/togetherjava/tjbot/commands/code/FormatCodeCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/code/FormatCodeCommand.java
index 2a3b086cc4..2072daf6ba 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/code/FormatCodeCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/code/FormatCodeCommand.java
@@ -1,9 +1,9 @@
-package org.togetherjava.tjbot.commands.code;
+package org.togetherjava.tjbot.features.code;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.togetherjava.tjbot.commands.utils.CodeFence;
+import org.togetherjava.tjbot.features.utils.CodeFence;
import org.togetherjava.tjbot.formatter.Formatter;
/**
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/code/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/code/package-info.java
similarity index 86%
rename from application/src/main/java/org/togetherjava/tjbot/commands/code/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/code/package-info.java
index b8adb1ffd2..96a49d9332 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/code/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/code/package-info.java
@@ -3,7 +3,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.code;
+package org.togetherjava.tjbot.features.code;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentId.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java
similarity index 82%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentId.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java
index 5e297c7576..d77edfb132 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentId.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -6,7 +6,7 @@
/**
* Payload carried by component IDs. See
- * {@link org.togetherjava.tjbot.commands.SlashCommand#onSlashCommand(SlashCommandInteractionEvent)}
+ * {@link org.togetherjava.tjbot.features.SlashCommand#onSlashCommand(SlashCommandInteractionEvent)}
* for its usages.
*
* @param userInteractorName the name of the user interactor that handles the event associated to
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdGenerator.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdGenerator.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdGenerator.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdGenerator.java
index 372e6ed54f..55d3b460de 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdGenerator.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdGenerator.java
@@ -1,11 +1,11 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
-import org.togetherjava.tjbot.commands.SlashCommand;
+import org.togetherjava.tjbot.features.SlashCommand;
/**
* Provides component ID generation.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdInteractor.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdInteractor.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdInteractor.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdInteractor.java
index 77792aafad..438c143f08 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdInteractor.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdInteractor.java
@@ -1,9 +1,9 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
-import org.togetherjava.tjbot.commands.SlashCommand;
-import org.togetherjava.tjbot.commands.UserInteractionType;
+import org.togetherjava.tjbot.features.SlashCommand;
+import org.togetherjava.tjbot.features.UserInteractionType;
import java.util.Arrays;
import java.util.Objects;
@@ -15,7 +15,7 @@
* The method {@link #acceptComponentIdGenerator(ComponentIdGenerator)} must be used before
* attempting to generate IDs.
*
- * Mostly used by classes implementing {@link org.togetherjava.tjbot.commands.UserInteractor}, to
+ * Mostly used by classes implementing {@link org.togetherjava.tjbot.features.UserInteractor}, to
* simplify handling with the IDs.
*/
public final class ComponentIdInteractor {
@@ -42,7 +42,7 @@ public ComponentIdInteractor(UserInteractionType userInteractionType, String nam
*
* It will provide the interactor a component ID generator through this method, which can be
* used to generate component IDs, as used for button or selection menus. See
- * {@link org.togetherjava.tjbot.commands.UserInteractor#acceptComponentIdGenerator(ComponentIdGenerator)}
+ * {@link org.togetherjava.tjbot.features.UserInteractor#acceptComponentIdGenerator(ComponentIdGenerator)}
* for details on how to use this.
*
* @param generator the provided component ID generator
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdParser.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdParser.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdParser.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdParser.java
index 83173f0474..251fcec9cb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdParser.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdParser.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
@@ -14,7 +14,7 @@
* are persisted by the system.
*
* See
- * {@link org.togetherjava.tjbot.commands.SlashCommand#onSlashCommand(SlashCommandInteractionEvent)}
+ * {@link org.togetherjava.tjbot.features.SlashCommand#onSlashCommand(SlashCommandInteractionEvent)}
* for more context on how to use this.
*
* The interface {@link ComponentIdGenerator} is the counterpart to this, offering generation of IDs
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdStore.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdStore.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdStore.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdStore.java
index 223593526c..4dbdc25ffe 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdStore.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentIdStore.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
@@ -9,10 +9,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.SlashCommand;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.ComponentIds;
import org.togetherjava.tjbot.db.generated.tables.records.ComponentIdsRecord;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.logging.LogMarkers;
import java.time.Instant;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/InvalidComponentIdFormatException.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java
similarity index 92%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/InvalidComponentIdFormatException.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java
index 99b2f9a825..01200f6357 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/InvalidComponentIdFormatException.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import java.io.Serial;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/Lifespan.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/Lifespan.java
similarity index 91%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/Lifespan.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/Lifespan.java
index b9d8d05d63..53513c7139 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/Lifespan.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/Lifespan.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
/**
* The lifespan of a component ID. Controls when it will be targeted for eviction and expire.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/package-info.java
similarity index 63%
rename from application/src/main/java/org/togetherjava/tjbot/commands/componentids/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/componentids/package-info.java
index f982878027..61867fdf50 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/componentids/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/package-info.java
@@ -2,17 +2,17 @@
* This package provides utilities to generate, persist and parse component IDs.
*
* See
- * {@link org.togetherjava.tjbot.commands.SlashCommand#onSlashCommand(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)}
+ * {@link org.togetherjava.tjbot.features.SlashCommand#onSlashCommand(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)}
* for details on component IDs.
*
- * The class {@link org.togetherjava.tjbot.commands.componentids.ComponentIdStore} is the central
+ * The class {@link org.togetherjava.tjbot.features.componentids.ComponentIdStore} is the central
* point of this package and is generally exposed as
- * {@link org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator} and
- * {@link org.togetherjava.tjbot.commands.componentids.ComponentIdParser}.
+ * {@link org.togetherjava.tjbot.features.componentids.ComponentIdGenerator} and
+ * {@link org.togetherjava.tjbot.features.componentids.ComponentIdParser}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.componentids;
+package org.togetherjava.tjbot.features.componentids;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/FileSharingMessageListener.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/filesharing/FileSharingMessageListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java
index 7ee09f4b7e..01ae063b97 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/FileSharingMessageListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.filesharing;
+package org.togetherjava.tjbot.features.filesharing;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -18,12 +18,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
-import org.togetherjava.tjbot.commands.UserInteractionType;
-import org.togetherjava.tjbot.commands.UserInteractor;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdInteractor;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
+import org.togetherjava.tjbot.features.UserInteractionType;
+import org.togetherjava.tjbot.features.UserInteractor;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor;
import java.io.IOException;
import java.io.InputStream;
@@ -70,11 +70,9 @@ public class FileSharingMessageListener extends MessageReceiverAdapter implement
* Creates a new instance.
*
* @param config used to get api key and channel names.
- * @see org.togetherjava.tjbot.commands.Features
+ * @see org.togetherjava.tjbot.features.Features
*/
public FileSharingMessageListener(Config config) {
- super(Pattern.compile(".*"));
-
gistApiKey = config.getGistApiKey();
isHelpForumName =
Pattern.compile(config.getHelpSystem().getHelpForumPattern()).asMatchPredicate();
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistFile.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistFile.java
similarity index 74%
rename from application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistFile.java
rename to application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistFile.java
index 343a7a1730..2b9ece5ec5 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistFile.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistFile.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.filesharing;
+package org.togetherjava.tjbot.features.filesharing;
/**
* @see Create a Gist via
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistFiles.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistFiles.java
similarity index 83%
rename from application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistFiles.java
rename to application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistFiles.java
index 1541a676c7..24ce25ee7e 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistFiles.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistFiles.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.filesharing;
+package org.togetherjava.tjbot.features.filesharing;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistRequest.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistRequest.java
similarity index 83%
rename from application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistRequest.java
rename to application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistRequest.java
index 6b1dd78575..c15154e845 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistRequest.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistRequest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.filesharing;
+package org.togetherjava.tjbot.features.filesharing;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistResponse.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistResponse.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistResponse.java
rename to application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistResponse.java
index 3e193c533d..cd4e2fd6f6 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/GistResponse.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/GistResponse.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.filesharing;
+package org.togetherjava.tjbot.features.filesharing;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/package-info.java
similarity index 74%
rename from application/src/main/java/org/togetherjava/tjbot/commands/filesharing/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/filesharing/package-info.java
index f1ef60813e..42c5ec7b37 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/filesharing/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/package-info.java
@@ -1,10 +1,10 @@
/**
* This package offers all the functionality for automatically uploading files to sharing services.
- * The core class is {@link org.togetherjava.tjbot.commands.filesharing.FileSharingMessageListener}.
+ * The core class is {@link org.togetherjava.tjbot.features.filesharing.FileSharingMessageListener}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.filesharing;
+package org.togetherjava.tjbot.features.filesharing;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/AutoPruneHelperRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/help/AutoPruneHelperRoutine.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/AutoPruneHelperRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/AutoPruneHelperRoutine.java
index 22d95e45f7..183dd2ab79 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/AutoPruneHelperRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/AutoPruneHelperRoutine.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
@@ -8,10 +8,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
-import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
+import org.togetherjava.tjbot.features.Routine;
+import org.togetherjava.tjbot.features.moderation.audit.ModAuditLogWriter;
import java.time.Duration;
import java.time.Instant;
diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java
new file mode 100644
index 0000000000..0e4cff2eba
--- /dev/null
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java
@@ -0,0 +1,42 @@
+package org.togetherjava.tjbot.features.help;
+
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.MessageEmbed;
+import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
+import net.dv8tion.jda.api.hooks.ListenerAdapter;
+
+import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.EventReceiver;
+
+/**
+ * Remove all thread channels associated to a user when they leave the guild.
+ */
+public final class GuildLeaveCloseThreadListener extends ListenerAdapter implements EventReceiver {
+ private final String helpForumPattern;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param config the config to get help forum channel pattern from
+ */
+ public GuildLeaveCloseThreadListener(Config config) {
+ this.helpForumPattern = config.getHelpSystem().getHelpForumPattern();
+ }
+
+ @Override
+ public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
+ MessageEmbed embed = new EmbedBuilder().setTitle("OP left")
+ .setDescription("Closing thread...")
+ .setColor(HelpSystemHelper.AMBIENT_COLOR)
+ .build();
+
+ event.getGuild()
+ .retrieveActiveThreads()
+ .queue(threads -> threads.stream()
+ .filter(thread -> thread.getOwnerIdLong() == event.getUser().getIdLong())
+ .filter(thread -> thread.getParentChannel().getName().matches(helpForumPattern))
+ .forEach(thread -> thread.sendMessageEmbeds(embed)
+ .flatMap(any -> thread.getManager().setArchived(true))
+ .queue()));
+ }
+}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpSystemHelper.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/HelpSystemHelper.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java
index e66fea0997..1bae9c6b1d 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpSystemHelper.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
@@ -19,12 +19,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.HelpSystemConfig;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.HelpThreads;
import org.togetherjava.tjbot.db.generated.tables.records.HelpThreadsRecord;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadActivityUpdater.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadActivityUpdater.java
similarity index 74%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadActivityUpdater.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadActivityUpdater.java
index 4b21fb37e8..aa223c9d7c 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadActivityUpdater.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadActivityUpdater.java
@@ -1,8 +1,11 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.MessageHistory;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
@@ -11,8 +14,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
+import org.togetherjava.tjbot.features.Routine;
+import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -30,8 +34,14 @@ public final class HelpThreadActivityUpdater implements Routine {
private static final Logger logger = LoggerFactory.getLogger(HelpThreadActivityUpdater.class);
private static final int SCHEDULE_MINUTES = 30;
private static final int ACTIVITY_DETERMINE_MESSAGE_LIMIT = 11;
-
+ private static final int CHANNEL_ACTIVITY_CACHE_LIFETIME = 12;
+ private static final ChronoUnit CHANNEL_ACTIVITY_CACHE_LIFETIME_UNIT = ChronoUnit.HOURS;
private final HelpSystemHelper helper;
+ public static final Cache manuallyResetChannelActivityCache = Caffeine.newBuilder()
+ .maximumSize(1_000)
+ .expireAfterWrite(CHANNEL_ACTIVITY_CACHE_LIFETIME,
+ TimeUnit.of(CHANNEL_ACTIVITY_CACHE_LIFETIME_UNIT))
+ .build();
/**
* Creates a new instance.
@@ -78,7 +88,8 @@ private void updateActivityForThread(ThreadChannel threadChannel) {
private static RestAction determineActivity(
MessageChannel channel) {
- return channel.getHistory().retrievePast(ACTIVITY_DETERMINE_MESSAGE_LIMIT).map(messages -> {
+
+ return getRelevantHistory(channel).map(messages -> {
if (messages.size() >= ACTIVITY_DETERMINE_MESSAGE_LIMIT) {
// There are likely even more messages, but we hit the limit
return HelpSystemHelper.ThreadActivity.HIGH;
@@ -97,6 +108,16 @@ private static RestAction determineActivity(
});
}
+ private static RestAction> getRelevantHistory(MessageChannel channel) {
+ Long mostRecentMessageId =
+ manuallyResetChannelActivityCache.getIfPresent(channel.getIdLong());
+
+ return mostRecentMessageId != null
+ ? channel.getHistoryAfter(mostRecentMessageId, ACTIVITY_DETERMINE_MESSAGE_LIMIT)
+ .map(MessageHistory::getRetrievedHistory)
+ : channel.getHistory().retrievePast(ACTIVITY_DETERMINE_MESSAGE_LIMIT);
+ }
+
private static boolean isBotMessage(Message message) {
return message.getAuthor().equals(message.getJDA().getSelfUser());
}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadAutoArchiver.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java
index 8cb853e199..a0f5121495 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadAutoArchiver.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
@@ -11,7 +11,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
+import org.togetherjava.tjbot.features.Routine;
import java.time.Duration;
import java.time.Instant;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java
similarity index 85%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java
index 5ca8c3eab6..a2b1a123a3 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java
@@ -1,12 +1,9 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Guild;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.Role;
+import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.InteractionHook;
@@ -17,9 +14,9 @@
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
@@ -31,6 +28,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static org.togetherjava.tjbot.features.help.HelpThreadActivityUpdater.manuallyResetChannelActivityCache;
+
/**
* Implements the {@code /help-thread} command, used to maintain certain aspects of help threads,
* such as renaming or closing them.
@@ -42,6 +41,8 @@ public final class HelpThreadCommand extends SlashCommandAdapter {
private static final String CHANGE_CATEGORY_OPTION = "category";
public static final String CHANGE_TITLE_SUBCOMMAND = "title";
private static final String CHANGE_TITLE_OPTION = "title";
+ private static final String CLOSE_SUBCOMMAND = "close";
+ private static final String RESET_ACTIVITY_SUBCOMMAND = "reset-activity";
public static final String CHANGE_SUBCOMMAND_GROUP = "change";
public static final String COMMAND_NAME = "help-thread";
@@ -80,6 +81,7 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) {
getData().addSubcommandGroups(changeCommands);
getData().addSubcommands(Subcommand.CLOSE.toSubcommandData());
+ getData().addSubcommands(Subcommand.RESET_ACTIVITY.toSubcommandData());
this.helper = helper;
@@ -92,9 +94,9 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) {
subcommandToCooldownCache = new EnumMap<>(streamSubcommands()
.filter(Subcommand::hasCooldown)
.collect(Collectors.toMap(Function.identity(), any -> createCooldownCache.get())));
- subcommandToEventHandler = new EnumMap<>(
- Map.of(Subcommand.CHANGE_CATEGORY, this::changeCategory, Subcommand.CHANGE_TITLE,
- this::changeTitle, Subcommand.CLOSE, this::closeThread));
+ subcommandToEventHandler = new EnumMap<>(Map.of(Subcommand.CHANGE_CATEGORY,
+ this::changeCategory, Subcommand.CHANGE_TITLE, this::changeTitle, Subcommand.CLOSE,
+ this::closeThread, Subcommand.RESET_ACTIVITY, this::resetActivity));
}
@Override
@@ -198,6 +200,19 @@ private void closeThread(SlashCommandInteractionEvent event, ThreadChannel helpT
event.replyEmbeds(embed).flatMap(any -> helpThread.getManager().setArchived(true)).queue();
}
+ private void resetActivity(SlashCommandInteractionEvent event, ThreadChannel helpThread) {
+ refreshCooldownFor(Subcommand.RESET_ACTIVITY, helpThread);
+
+ helpThread.getHistory()
+ .retrievePast(1)
+ .map(messages -> messages.get(0))
+ .queue(lastMessage -> manuallyResetChannelActivityCache.put(helpThread.getIdLong(),
+ lastMessage.getIdLong()));
+
+ helper.changeChannelActivity(helpThread, HelpSystemHelper.ThreadActivity.LOW);
+ event.reply("Activities have been reset.").queue();
+ }
+
private static Stream streamSubcommands() {
return Arrays.stream(Subcommand.values());
}
@@ -206,7 +221,10 @@ enum Subcommand {
CHANGE_CATEGORY(CHANGE_CATEGORY_SUBCOMMAND, "Change the category of this help thread",
Cooldown.YES),
CHANGE_TITLE(CHANGE_TITLE_SUBCOMMAND, "Change the title of this help thread", Cooldown.YES),
- CLOSE("close", "Close this help thread", Cooldown.YES);
+ CLOSE(CLOSE_SUBCOMMAND, "Close this help thread", Cooldown.YES),
+ RESET_ACTIVITY(RESET_ACTIVITY_SUBCOMMAND,
+ "Resets the activity indicator, use if help is still needed, but the indicator shows otherwise",
+ Cooldown.YES);
private final String commandName;
private final String description;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadCreatedListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadCreatedListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java
index 002e7df3bf..f707ad5821 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadCreatedListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -12,7 +12,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.EventReceiver;
+import org.togetherjava.tjbot.features.EventReceiver;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadMetadataPurger.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadMetadataPurger.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadMetadataPurger.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadMetadataPurger.java
index 34c6d3c644..457a222a4a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/HelpThreadMetadataPurger.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadMetadataPurger.java
@@ -1,12 +1,12 @@
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import net.dv8tion.jda.api.JDA;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.HelpThreads;
+import org.togetherjava.tjbot.features.Routine;
import java.time.Instant;
import java.time.Period;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/help/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/help/package-info.java
similarity index 76%
rename from application/src/main/java/org/togetherjava/tjbot/commands/help/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/help/package-info.java
index 4278f5e1ac..ba81a604dc 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/help/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/help/package-info.java
@@ -1,11 +1,11 @@
/**
* This package offers all functionality for the help system. For example commands that handles the
* actions taken after creating a help thread
- * {@link org.togetherjava.tjbot.commands.help.HelpThreadCreatedListener}.
+ * {@link org.togetherjava.tjbot.features.help.HelpThreadCreatedListener}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.help;
+package org.togetherjava.tjbot.features.help;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/TeXCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/TeXCommand.java
index 4bfd4ec0d2..d3bc822fca 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/TeXCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands;
+package org.togetherjava.tjbot.features.mathcommands;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
@@ -13,8 +13,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import javax.imageio.ImageIO;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/package-info.java
similarity index 81%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/package-info.java
index 27b8f73b65..4800edb6a6 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/package-info.java
@@ -3,7 +3,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.mathcommands;
+package org.togetherjava.tjbot.features.mathcommands;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaCommand.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaCommand.java
index bd0884cf55..7f37ab6d0a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha;
import io.mikael.urlbuilder.UrlBuilder;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -6,9 +6,9 @@
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.utils.FileUpload;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaHandler.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaHandler.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java
index 82a375ecc2..ca17d32346 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaHandler.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.mikael.urlbuilder.UrlBuilder;
@@ -8,8 +8,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api.*;
-import org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api.Error;
+import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.*;
+import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Error;
import java.awt.Color;
import java.awt.image.BufferedImage;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaImages.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaImages.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java
index 25cff2c349..1da467e528 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/WolframAlphaImages.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java
@@ -1,7 +1,7 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha;
-import org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api.SubPod;
-import org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api.WolframAlphaImage;
+import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.SubPod;
+import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.WolframAlphaImage;
import javax.imageio.ImageIO;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/DidYouMean.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/DidYouMean.java
similarity index 89%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/DidYouMean.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/DidYouMean.java
index f5eed82762..f5c3f6ae57 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/DidYouMean.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/DidYouMean.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/DidYouMeans.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/DidYouMeans.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/DidYouMeans.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/DidYouMeans.java
index ff5eb47017..9b0cedb346 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/DidYouMeans.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/DidYouMeans.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Error.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Error.java
similarity index 91%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Error.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Error.java
index fa8bcfa3db..995bf36662 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Error.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Error.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/ExamplePage.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/ExamplePage.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/ExamplePage.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/ExamplePage.java
index a07f6bd5f4..1b3513928b 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/ExamplePage.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/ExamplePage.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/FutureTopic.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/FutureTopic.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/FutureTopic.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/FutureTopic.java
index 0e6e23f457..e2027dfa70 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/FutureTopic.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/FutureTopic.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/LanguageMessage.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/LanguageMessage.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/LanguageMessage.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/LanguageMessage.java
index c352af94c8..d6576211de 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/LanguageMessage.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/LanguageMessage.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/PlainText.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/PlainText.java
similarity index 88%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/PlainText.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/PlainText.java
index 8b5d85ac4f..6e4dd20b33 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/PlainText.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/PlainText.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Pod.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Pod.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Pod.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Pod.java
index 1b625104ea..efff80e94e 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Pod.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Pod.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/QueryResult.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/QueryResult.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/QueryResult.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/QueryResult.java
index 928e5988d3..15579560e8 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/QueryResult.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/QueryResult.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
@@ -216,7 +216,7 @@ public void setRelatedExamples(RelatedExamples relatedExamples) {
}
@SuppressWarnings("unused")
- public org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api.Error getErrorTag() {
+ public org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Error getErrorTag() {
return errorTag;
}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/RelatedExample.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/RelatedExample.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/RelatedExample.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/RelatedExample.java
index 4410421dcf..bfc3570805 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/RelatedExample.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/RelatedExample.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/RelatedExamples.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/RelatedExamples.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/RelatedExamples.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/RelatedExamples.java
index b7a3253573..7899f42bef 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/RelatedExamples.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/RelatedExamples.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/SubPod.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/SubPod.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/SubPod.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/SubPod.java
index e1fc2f1682..089201df1e 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/SubPod.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/SubPod.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Tip.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Tip.java
similarity index 89%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Tip.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Tip.java
index 04936258cd..a3736290de 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Tip.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Tip.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Tips.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Tips.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Tips.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Tips.java
index 0e3a9947de..26d4b3b0e2 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/Tips.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/Tips.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/WolframAlphaImage.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/WolframAlphaImage.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/WolframAlphaImage.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/WolframAlphaImage.java
index d7d3bdf641..0e1ae52666 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/WolframAlphaImage.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/WolframAlphaImage.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/package-info.java
similarity index 85%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/package-info.java
index 39db8406b2..134f7abde3 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/api/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/api/package-info.java
@@ -5,7 +5,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha.api;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha.api;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/package-info.java
similarity index 84%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/package-info.java
index ec0a220c02..029ee3db3e 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/wolframalpha/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/package-info.java
@@ -4,7 +4,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.mathcommands.wolframalpha;
+package org.togetherjava.tjbot.features.mathcommands.wolframalpha;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mediaonly/MediaOnlyChannelListener.java b/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mediaonly/MediaOnlyChannelListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java
index e9fc277b5c..5f7b6c55ef 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mediaonly/MediaOnlyChannelListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mediaonly;
+package org.togetherjava.tjbot.features.mediaonly;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
@@ -9,8 +9,8 @@
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
import java.awt.Color;
import java.util.regex.Pattern;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/mediaonly/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/package-info.java
similarity index 85%
rename from application/src/main/java/org/togetherjava/tjbot/commands/mediaonly/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/mediaonly/package-info.java
index f4321f676a..5487520cc8 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/mediaonly/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/package-info.java
@@ -3,7 +3,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.mediaonly;
+package org.togetherjava.tjbot.features.mediaonly;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ActionRecord.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ActionRecord.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/ActionRecord.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/ActionRecord.java
index 080db80c14..ec48e684e0 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ActionRecord.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ActionRecord.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import org.togetherjava.tjbot.db.generated.tables.records.ModerationActionsRecord;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java
similarity index 84%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java
index 751c15679e..a298a8e1ed 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java
@@ -1,8 +1,7 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.interactions.InteractionHook;
@@ -13,12 +12,11 @@
import net.dv8tion.jda.api.requests.ErrorResponse;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -45,6 +43,7 @@ public final class BanCommand extends SlashCommandAdapter {
private static final String REASON_OPTION = "reason";
private static final String COMMAND_NAME = "ban";
private static final String ACTION_VERB = "ban";
+ private static final String ACTION_TITLE = "Ban";
@SuppressWarnings("StaticCollection")
private static final List DURATIONS = List.of(ModerationUtils.PERMANENT_DURATION,
"1 hour", "3 hours", "1 day", "2 days", "3 days", "7 days", "30 days");
@@ -72,35 +71,26 @@ public BanCommand(ModerationActionsStore actionsStore) {
this.actionsStore = Objects.requireNonNull(actionsStore);
}
- private static RestAction handleAlreadyBanned(Guild.Ban ban,
- IReplyCallback event) {
+ private static RestAction handleAlreadyBanned(Guild.Ban ban, InteractionHook hook) {
String reason = ban.getReason();
String reasonText =
reason == null || reason.isBlank() ? "" : " (reason: %s)".formatted(reason);
String message = "The user '%s' is already banned%s.".formatted(ban.getUser().getAsTag(),
reasonText);
- return event.reply(message).setEphemeral(true);
+ return hook.sendMessage(message).setEphemeral(true);
}
- private static RestAction sendDm(ISnowflake target,
- @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild,
- GenericEvent event) {
- String durationMessage =
- temporaryData == null ? "permanently" : "for " + temporaryData.duration();
- String dmMessage =
+ private static RestAction sendDm(User target,
+ @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild) {
+ String durationMessage = temporaryData == null ? "Permanently" : temporaryData.duration();
+ String description =
"""
- Hey there, sorry to tell you but unfortunately you have been banned %s from the server %s.
- If you think this was a mistake, please contact a moderator or admin of the server.
- The reason for the ban is: %s
- """
- .formatted(durationMessage, guild.getName(), reason);
-
- return event.getJDA()
- .openPrivateChannelById(target.getId())
- .flatMap(channel -> channel.sendMessage(dmMessage))
- .mapToResult()
- .map(Result::isSuccess);
+ Hey there, sorry to tell you but unfortunately you have been banned from the server.
+ If you think this was a mistake, please contact a moderator or admin of this server.""";
+
+ return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild,
+ ACTION_TITLE, description, reason, durationMessage, false), target);
}
private static MessageEmbed sendFeedback(boolean hasSentDm, User target, Member author,
@@ -115,8 +105,8 @@ private static MessageEmbed sendFeedback(boolean hasSentDm, User target, Member
durationText + dmNoticeText, reason);
}
- private static Optional> handleNotAlreadyBannedResponse(
- Throwable alreadyBannedFailure, IReplyCallback event, Guild guild, User target) {
+ private static Optional> handleNotAlreadyBannedResponse(
+ Throwable alreadyBannedFailure, InteractionHook hook, Guild guild, User target) {
if (alreadyBannedFailure instanceof ErrorResponseException errorResponseException) {
if (errorResponseException.getErrorResponse() == ErrorResponse.UNKNOWN_BAN) {
return Optional.empty();
@@ -125,7 +115,7 @@ private static Optional> handleNotAlreadyBannedRespo
if (errorResponseException.getErrorResponse() == ErrorResponse.MISSING_PERMISSIONS) {
logger.error("The bot does not have the '{}' permission on the guild '{}'.",
Permission.BAN_MEMBERS, guild.getName());
- return Optional.of(event.reply(
+ return Optional.of(hook.sendMessage(
"I can not ban users in this guild since I do not have the %s permission."
.formatted(Permission.BAN_MEMBERS))
.setEphemeral(true));
@@ -134,18 +124,18 @@ private static Optional> handleNotAlreadyBannedRespo
logger.warn(LogMarkers.SENSITIVE,
"Something unexpected went wrong while trying to ban the user '{}'.",
target.getAsTag(), alreadyBannedFailure);
- return Optional.of(event.reply("Failed to ban the user due to an unexpected problem.")
+ return Optional.of(hook.sendMessage("Failed to ban the user due to an unexpected problem.")
.setEphemeral(true));
}
- private RestAction banUserFlow(User target, Member author,
+ private RestAction banUserFlow(User target, Member author,
@Nullable ModerationUtils.TemporaryData temporaryData, String reason,
int deleteHistoryDays, Guild guild, SlashCommandInteractionEvent event) {
- return sendDm(target, temporaryData, reason, guild, event)
+ return sendDm(target, temporaryData, reason, guild)
.flatMap(hasSentDm -> banUser(target, author, temporaryData, reason, deleteHistoryDays,
guild).map(banResult -> hasSentDm))
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason))
- .flatMap(event::replyEmbeds);
+ .flatMap(event.getHook()::sendMessageEmbeds);
}
private AuditableRestAction banUser(User target, Member author,
@@ -208,14 +198,16 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
int deleteHistoryDays = Math
.toIntExact(Objects.requireNonNull(event.getOption(DELETE_HISTORY_OPTION)).getAsLong());
+ event.deferReply().queue();
+ InteractionHook hook = event.getHook();
// Ban the user, but only if not already banned
guild.retrieveBan(target).mapToResult().flatMap(alreadyBanned -> {
if (alreadyBanned.isSuccess()) {
- return handleAlreadyBanned(alreadyBanned.get(), event);
+ return handleAlreadyBanned(alreadyBanned.get(), hook);
}
return handleNotAlreadyBannedResponse(
- Objects.requireNonNull(alreadyBanned.getFailure()), event, guild, target)
+ Objects.requireNonNull(alreadyBanned.getFailure()), hook, guild, target)
.orElseGet(() -> banUserFlow(target, author, temporaryData.orElse(null),
reason, deleteHistoryDays, guild, event));
}).queue();
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/KickCommand.java
similarity index 80%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/KickCommand.java
index 696476a3e6..7a4d47fd85 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/KickCommand.java
@@ -1,22 +1,17 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.Permission;
-import net.dv8tion.jda.api.entities.Guild;
-import net.dv8tion.jda.api.entities.ISnowflake;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.events.GenericEvent;
+import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -36,6 +31,7 @@ public final class KickCommand extends SlashCommandAdapter {
private static final String REASON_OPTION = "reason";
private static final String COMMAND_NAME = "kick";
private static final String ACTION_VERB = "kick";
+ private static final String ACTION_TITLE = "Kick";
private final ModerationActionsStore actionsStore;
/**
@@ -60,27 +56,25 @@ private static void handleAbsentTarget(IReplyCallback event) {
private void kickUserFlow(Member target, Member author, String reason, Guild guild,
SlashCommandInteractionEvent event) {
- sendDm(target, reason, guild, event)
+ event.deferReply().queue();
+
+ sendDm(target.getUser(), reason, guild)
.flatMap(hasSentDm -> kickUser(target, author, reason, guild)
.map(kickResult -> hasSentDm))
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason))
- .flatMap(event::replyEmbeds)
+ .flatMap(event.getHook()::sendMessageEmbeds)
.queue();
}
- private static RestAction sendDm(ISnowflake target, String reason, Guild guild,
- GenericEvent event) {
- return event.getJDA()
- .openPrivateChannelById(target.getId())
- .flatMap(channel -> channel.sendMessage(
- """
- Hey there, sorry to tell you but unfortunately you have been kicked from the server %s.
- If you think this was a mistake, please contact a moderator or admin of the server.
- The reason for the kick is: %s
- """
- .formatted(guild.getName(), reason)))
- .mapToResult()
- .map(Result::isSuccess);
+ private static RestAction sendDm(User target, String reason, Guild guild) {
+ String description =
+ """
+ Hey there, sorry to tell you but unfortunately you have been kicked from the server.
+ If you think this was a mistake, please contact a moderator or admin of this server.""";
+
+ return ModerationUtils.sendModActionDm(
+ ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false),
+ target);
}
private AuditableRestAction kickUser(Member target, Member author, String reason,
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationAction.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationAction.java
index 635c69a2f1..4c4a3150b3 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationAction.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
/**
* All available moderation actions.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationActionsStore.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationActionsStore.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationActionsStore.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationActionsStore.java
index 06248d51c5..3d0aa2706e 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationActionsStore.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationActionsStore.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import org.jooq.Condition;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java
similarity index 80%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java
index b4877fc0e5..f8408a520f 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationUtils.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java
@@ -1,18 +1,19 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
+import net.dv8tion.jda.api.utils.Result;
+import net.dv8tion.jda.internal.requests.CompletedRestAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.moderation.modmail.ModMailCommand;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.moderation.modmail.ModMailCommand;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import javax.annotation.Nullable;
@@ -20,11 +21,8 @@
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
-import java.util.EnumSet;
import java.util.Optional;
-import java.util.Set;
import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
import java.util.regex.Pattern;
/**
@@ -50,26 +48,7 @@ private ModerationUtils() {
* The ambient color used by moderation actions, often used to streamline the color theme of
* embeds.
*/
- static final Color AMBIENT_COLOR = Color.decode("#895FE8");
-
- /**
- * Actions with timely constraint, like being muted for 1 hour.
- */
- private static final Set TEMPORARY_ACTIONS =
- EnumSet.of(ModerationAction.MUTE);
- /**
- * Actions with revoking previously made actions on the user, like unmuting the user after it
- * has been muted.
- */
- private static final Set REVOKE_ACTIONS =
- EnumSet.of(ModerationAction.UNMUTE, ModerationAction.UNQUARANTINE);
- /**
- * Soft violations were the user still remains member of the guild, such as a warning
- */
- private static final Set SOFT_ACTIONS =
- EnumSet.of(ModerationAction.WARN, ModerationAction.QUARANTINE);
-
-
+ public static final Color AMBIENT_COLOR = Color.decode("#895FE8");
/**
* Checks whether the given reason is valid. If not, it will handle the situation and respond to
@@ -105,7 +84,7 @@ static boolean handleReason(CharSequence reason, IReplyCallback event) {
* @param event the event used to respond to the user
* @return Whether the author and bot can interact with the target user
*/
- static boolean handleCanInteractWithTarget(String actionVerb, Member bot, Member author,
+ public static boolean handleCanInteractWithTarget(String actionVerb, Member bot, Member author,
Member target, IReplyCallback event) {
String targetTag = target.getUser().getAsTag();
if (!author.canInteract(target)) {
@@ -390,64 +369,71 @@ static Optional computeTemporaryData(String durationText) {
}
/**
- * Wrapper to hold data relevant to temporary actions, for example the time it expires.
+ * Creates a nice looking embed for the mod action taken.
*
- * @param expiresAt the time the temporary action expires
- * @param duration a human-readable text representing the duration of the temporary action, such
- * as {@code "1 day"}.
+ * @param guild the guild in which the action has been taken
+ * @param actionTitle the mod action as title e.g, Ban
+ * @param description a short description explaining the action
+ * @param reason reason for the action taken
+ * @param showModmailAdvice whether to advice on how to use the modmail command
+ * @return the embed
*/
- record TemporaryData(Instant expiresAt, String duration) {
+ static RestAction getModActionEmbed(Guild guild, String actionTitle,
+ String description, String reason, boolean showModmailAdvice) {
+ EmbedBuilder modActionEmbed =
+ new EmbedBuilder().setAuthor(guild.getName(), null, guild.getIconUrl())
+ .setTitle(actionTitle)
+ .setDescription(description)
+ .addField("Reason", reason, false)
+ .setColor(ModerationUtils.AMBIENT_COLOR);
+
+ if (!showModmailAdvice) {
+ return new CompletedRestAction<>(guild.getJDA(), modActionEmbed);
+ }
+
+ return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME)
+ .map(commandMention -> modActionEmbed.appendDescription(
+ "%n%nTo get in touch with a moderator, you can use the %s command here in this chat. Your message will then be forwarded and a moderator will get back to you soon 😊"
+ .formatted(commandMention)));
}
/**
- * Gives out advice depending on the {@link ModerationAction} and the parameters passed into it.
+ * Creates a nice looking embed for the mod action taken with duration
*
- * @param action the action that is being performed, such as banning a user.
- * @param temporaryData if the action is a temporary action, such as a 1 hour mute.
- * @param additionalDescription any extra description that should be part of the message, if
- * desired
- * @param guild for which the action was triggered.
- * @param reason for the action.
- * @param textChannel for which messages are being sent to.
- *
- * @return the appropriate advice.
+ * @param guild the guild in which the action has been taken
+ * @param actionTitle the mod action itself
+ * @param description a short description explaining the action
+ * @param reason reason for the action taken
+ * @param duration the duration of mod action
+ * @param showModmailAdvice whether to advice on how to use the modmail command
+ * @return the embed
*/
- public static RestAction sendDmAdvice(ModerationAction action,
- @Nullable TemporaryData temporaryData, @Nullable String additionalDescription,
- Guild guild, String reason, PrivateChannel textChannel) {
- String additionalDescriptionInfix =
- additionalDescription == null ? "" : "\n" + additionalDescription;
-
- if (REVOKE_ACTIONS.contains(action)) {
- return textChannel.sendMessage("""
- Hey there, you have been %s in the server %s.%s
- The reason for being %s is: %s
- """.formatted(action.getVerb(), guild.getName(), additionalDescriptionInfix,
- action.getVerb(), reason));
- }
- String durationMessage;
- if (SOFT_ACTIONS.contains(action)) {
- durationMessage = "";
- } else if (TEMPORARY_ACTIONS.contains(action)) {
- durationMessage =
- temporaryData == null ? " permanently" : " for " + temporaryData.duration();
- } else {
- throw new IllegalArgumentException(
- "Action '%s' is not supported by this method".formatted(action));
- }
+ static RestAction getModActionEmbed(Guild guild, String actionTitle,
+ String description, String reason, String duration, boolean showModmailAdvice) {
+ return getModActionEmbed(guild, actionTitle, description, reason, showModmailAdvice)
+ .map(embedBuilder -> embedBuilder.addField("Duration", duration, false));
+ }
- UnaryOperator createDmMessage =
- commandMention -> """
- Hey there, sorry to tell you but unfortunately you have been %s%s in the server %s.%s
- To get in touch with a moderator, you can simply use the %s command here in this chat. \
- Your message will then be forwarded and a moderator will get back to you soon 😊
- The reason for being %s is: %s
- """
- .formatted(action.getVerb(), durationMessage, guild.getName(),
- additionalDescriptionInfix, commandMention, action.getVerb(), reason);
+ /**
+ * @param embedBuilder rest action to generate embed from
+ * @param target the user to send the generated embed
+ * @return boolean rest action, weather the dm is sent successfully
+ */
+ static RestAction sendModActionDm(RestAction embedBuilder, User target) {
+ return embedBuilder.map(EmbedBuilder::build)
+ .flatMap(embed -> target.openPrivateChannel()
+ .flatMap(channel -> channel.sendMessageEmbeds(embed)))
+ .mapToResult()
+ .map(Result::isSuccess);
+ }
- return MessageUtils.mentionGlobalSlashCommand(guild.getJDA(), ModMailCommand.COMMAND_NAME)
- .map(createDmMessage)
- .flatMap(textChannel::sendMessage);
+ /**
+ * Wrapper to hold data relevant to temporary actions, for example the time it expires.
+ *
+ * @param expiresAt the time the temporary action expires
+ * @param duration a human-readable text representing the duration of the temporary action, such
+ * as {@code "1 day"}.
+ */
+ record TemporaryData(Instant expiresAt, String duration) {
}
}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/MuteCommand.java
similarity index 87%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/MuteCommand.java
index 94a4efed9a..4c0f3307fd 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/MuteCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/MuteCommand.java
@@ -1,20 +1,18 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -38,6 +36,7 @@ public final class MuteCommand extends SlashCommandAdapter {
private static final String REASON_OPTION = "reason";
private static final String COMMAND_NAME = "mute";
private static final String ACTION_VERB = "mute";
+ private static final String ACTION_TITLE = "Mute";
@SuppressWarnings("StaticCollection")
private static final List DURATIONS = List.of("10 minutes", "30 minutes", "1 hour",
"3 hours", "1 day", "3 days", "7 days", ModerationUtils.PERMANENT_DURATION);
@@ -70,16 +69,16 @@ private static void handleAlreadyMutedTarget(IReplyCallback event) {
event.reply("The user is already muted.").setEphemeral(true).queue();
}
- private static RestAction sendDm(ISnowflake target,
- @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild,
- GenericEvent event) {
- return event.getJDA()
- .openPrivateChannelById(target.getId())
- .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.MUTE, temporaryData,
- "This means you can no longer send any messages in the server until you have been unmuted again.",
- guild, reason, channel))
- .mapToResult()
- .map(Result::isSuccess);
+ private static RestAction sendDm(User target,
+ @Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild) {
+ String durationMessage = temporaryData == null ? "Permanent" : temporaryData.duration();
+ String description =
+ """
+ Hey there, sorry to tell you but unfortunately you have been muted.
+ This means you can no longer send any messages in the server until you have been unmuted again.""";
+
+ return ModerationUtils.sendModActionDm(ModerationUtils.getModActionEmbed(guild,
+ ACTION_TITLE, description, reason, durationMessage, true), target);
}
private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author,
@@ -115,11 +114,13 @@ private AuditableRestAction muteUser(Member target, Member author,
private void muteUserFlow(Member target, Member author,
@Nullable ModerationUtils.TemporaryData temporaryData, String reason, Guild guild,
SlashCommandInteractionEvent event) {
- sendDm(target, temporaryData, reason, guild, event)
+ event.deferReply().queue();
+
+ sendDm(target.getUser(), temporaryData, reason, guild)
.flatMap(hasSentDm -> muteUser(target, author, temporaryData, reason, guild)
.map(result -> hasSentDm))
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason))
- .flatMap(event::replyEmbeds)
+ .flatMap(event.getHook()::sendMessageEmbeds)
.queue();
}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/NoteCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/NoteCommand.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/NoteCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/NoteCommand.java
index 12287abe45..793ce20e21 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/NoteCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/NoteCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -8,8 +8,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.moderation.audit.AuditCommand;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/QuarantineCommand.java
similarity index 85%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/QuarantineCommand.java
index dffb29292e..07dd3cdff9 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/QuarantineCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/QuarantineCommand.java
@@ -1,19 +1,17 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -34,6 +32,7 @@ public final class QuarantineCommand extends SlashCommandAdapter {
private static final String REASON_OPTION = "reason";
private static final String COMMAND_NAME = "quarantine";
private static final String ACTION_VERB = "quarantine";
+ private static final String ACTION_TITLE = "Quarantine";
private final ModerationActionsStore actionsStore;
private final Config config;
@@ -61,15 +60,15 @@ private static void handleAlreadyQuarantinedTarget(IReplyCallback event) {
event.reply("The user is already quarantined.").setEphemeral(true).queue();
}
- private static RestAction sendDm(ISnowflake target, String reason, Guild guild,
- GenericEvent event) {
- return event.getJDA()
- .openPrivateChannelById(target.getIdLong())
- .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.QUARANTINE, null,
- "This means you can no longer interact with anyone in the server until you have been unquarantined again.",
- guild, reason, channel))
- .mapToResult()
- .map(Result::isSuccess);
+ private static RestAction sendDm(User target, String reason, Guild guild) {
+ String description =
+ """
+ Hey there, sorry to tell you but unfortunately you have been put under quarantine.
+ This means you can no longer interact with anyone in the server until you have been unquarantined again.""";
+
+ return ModerationUtils.sendModActionDm(
+ ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, true),
+ target);
}
private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author,
@@ -100,11 +99,13 @@ private AuditableRestAction quarantineUser(Member target, Member author, S
private void quarantineUserFlow(Member target, Member author, String reason, Guild guild,
SlashCommandInteractionEvent event) {
- sendDm(target, reason, guild, event)
+ event.deferReply().queue();
+
+ sendDm(target.getUser(), reason, guild)
.flatMap(hasSentDm -> quarantineUser(target, author, reason, guild)
.map(result -> hasSentDm))
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason))
- .flatMap(event::replyEmbeds)
+ .flatMap(event.getHook()::sendMessageEmbeds)
.queue();
}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/RejoinModerationRoleListener.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/RejoinModerationRoleListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java
index 9ef3d59e75..35645e7ae7 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/RejoinModerationRoleListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.IPermissionHolder;
@@ -9,8 +9,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.EventReceiver;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.EventReceiver;
import org.togetherjava.tjbot.logging.LogMarkers;
import java.util.List;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ReportCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/ReportCommand.java
index e3fe2bd3ad..6f6dd4e7e6 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/ReportCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ReportCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -18,11 +18,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.BotCommandAdapter;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.MessageContextCommand;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.BotCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.MessageContextCommand;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import java.awt.*;
import java.time.Instant;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnbanCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/UnbanCommand.java
similarity index 96%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnbanCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/UnbanCommand.java
index f4fdc0239e..259be6ba62 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnbanCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/UnbanCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
@@ -10,8 +10,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import java.util.Objects;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/UnmuteCommand.java
similarity index 86%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/UnmuteCommand.java
index ce050fcd07..77de84206a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnmuteCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/UnmuteCommand.java
@@ -1,19 +1,17 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -33,6 +31,7 @@ public final class UnmuteCommand extends SlashCommandAdapter {
private static final String REASON_OPTION = "reason";
private static final String COMMAND_NAME = "unmute";
private static final String ACTION_VERB = "unmute";
+ private static final String ACTION_TITLE = "Unmute";
private final ModerationActionsStore actionsStore;
private final Config config;
@@ -58,15 +57,14 @@ private static void handleNotMutedTarget(IReplyCallback event) {
event.reply("The user is not muted.").setEphemeral(true).queue();
}
- private static RestAction sendDm(ISnowflake target, String reason, Guild guild,
- GenericEvent event) {
- return event.getJDA()
- .openPrivateChannelById(target.getId())
- .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.UNMUTE, null,
- "This means you can now send messages in the server again 👌", guild, reason,
- channel))
- .mapToResult()
- .map(Result::isSuccess);
+ private static RestAction sendDm(User target, String reason, Guild guild) {
+ String description = """
+ Hey there, you have been unmuted in the server.
+ This means you can now send messages in the server again 👌""";
+
+ return ModerationUtils.sendModActionDm(
+ ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false),
+ target);
}
private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author,
@@ -96,7 +94,7 @@ private AuditableRestAction unmuteUser(Member target, Member author, Strin
private void unmuteUserFlow(Member target, Member author, String reason, Guild guild,
SlashCommandInteractionEvent event) {
- sendDm(target, reason, guild, event)
+ sendDm(target.getUser(), reason, guild)
.flatMap(
hasSentDm -> unmuteUser(target, author, reason, guild).map(result -> hasSentDm))
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason))
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/UnquarantineCommand.java
similarity index 86%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/UnquarantineCommand.java
index 771d9e787f..6e0b3ea403 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnquarantineCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/UnquarantineCommand.java
@@ -1,19 +1,17 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -34,6 +32,7 @@ public final class UnquarantineCommand extends SlashCommandAdapter {
private static final String REASON_OPTION = "reason";
private static final String COMMAND_NAME = "unquarantine";
private static final String ACTION_VERB = "unquarantine";
+ private static final String ACTION_TITLE = "Unquarantine";
private final ModerationActionsStore actionsStore;
private final Config config;
@@ -62,15 +61,14 @@ private static void handleNotQuarantinedTarget(IReplyCallback event) {
event.reply("The user is not quarantined.").setEphemeral(true).queue();
}
- private static RestAction sendDm(ISnowflake target, String reason, Guild guild,
- GenericEvent event) {
- return event.getJDA()
- .openPrivateChannelById(target.getIdLong())
- .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.UNQUARANTINE, null,
- "This means you can now interact with others in the server again 👌", guild,
- reason, channel))
- .mapToResult()
- .map(Result::isSuccess);
+ private static RestAction sendDm(User target, String reason, Guild guild) {
+ String description = """
+ Hey there, you have been put out of quarantine in the server.
+ This means you can now interact with others in the server again 👌""";
+
+ return ModerationUtils.sendModActionDm(
+ ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, false),
+ target);
}
private static MessageEmbed sendFeedback(boolean hasSentDm, Member target, Member author,
@@ -101,7 +99,7 @@ private AuditableRestAction unquarantineUser(Member target, Member author,
private void unquarantineUserFlow(Member target, Member author, String reason, Guild guild,
SlashCommandInteractionEvent event) {
- sendDm(target, reason, guild, event)
+ sendDm(target.getUser(), reason, guild)
.flatMap(hasSentDm -> unquarantineUser(target, author, reason, guild)
.map(result -> hasSentDm))
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason))
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/WarnCommand.java
similarity index 80%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/WarnCommand.java
index 26b767b652..5221b78059 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WarnCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/WarnCommand.java
@@ -1,17 +1,15 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
-import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.RestAction;
-import net.dv8tion.jda.api.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.logging.LogMarkers;
import javax.annotation.Nullable;
@@ -30,6 +28,7 @@ public final class WarnCommand extends SlashCommandAdapter {
private static final String USER_OPTION = "user";
private static final String REASON_OPTION = "reason";
private static final String ACTION_VERB = "warn";
+ private static final String ACTION_TITLE = "Warning";
private final ModerationActionsStore actionsStore;
/**
@@ -46,24 +45,26 @@ public WarnCommand(ModerationActionsStore actionsStore) {
this.actionsStore = Objects.requireNonNull(actionsStore);
}
- private RestAction warnUserFlow(User target, Member author, String reason,
- Guild guild, SlashCommandInteractionEvent event) {
- return dmUser(target, reason, guild, event).map(hasSentDm -> {
+ private void warnUserFlow(User target, Member author, String reason, Guild guild,
+ SlashCommandInteractionEvent event) {
+ event.deferReply().queue();
+
+ sendDm(target, reason, guild).map(hasSentDm -> {
warnUser(target, author, reason, guild);
return hasSentDm;
})
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, reason))
- .flatMap(event::replyEmbeds);
+ .flatMap(event.getHook()::sendMessageEmbeds)
+ .queue();
}
- private static RestAction dmUser(ISnowflake target, String reason, Guild guild,
- SlashCommandInteractionEvent event) {
- return event.getJDA()
- .openPrivateChannelById(target.getId())
- .flatMap(channel -> ModerationUtils.sendDmAdvice(ModerationAction.WARN, null, null,
- guild, reason, channel))
- .mapToResult()
- .map(Result::isSuccess);
+ private static RestAction sendDm(User target, String reason, Guild guild) {
+ String description =
+ "Hey there, sorry to tell you but unfortunately you have been warned in the server.";
+
+ return ModerationUtils.sendModActionDm(
+ ModerationUtils.getModActionEmbed(guild, ACTION_TITLE, description, reason, true),
+ target);
}
private void warnUser(User target, Member author, String reason, Guild guild) {
@@ -99,7 +100,7 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
return;
}
- warnUserFlow(targetOption.getAsUser(), author, reason, guild, event).queue();
+ warnUserFlow(targetOption.getAsUser(), author, reason, guild, event);
}
private boolean handleChecks(Member bot, Member author, @Nullable Member target, String reason,
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WhoIsCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/WhoIsCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java
index e039343544..5460e0e102 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/WhoIsCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.*;
@@ -9,9 +9,9 @@
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.utils.DiscordClientAction;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.utils.DiscordClientAction;
import javax.annotation.CheckReturnValue;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/attachment/BlacklistedAttachmentListener.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/attachment/BlacklistedAttachmentListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java
index 6ec3819d55..db1060aefb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/attachment/BlacklistedAttachmentListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.attachment;
+package org.togetherjava.tjbot.features.moderation.attachment;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
@@ -9,17 +9,16 @@
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
-import org.togetherjava.tjbot.commands.moderation.modmail.ModMailCommand;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.config.Config;
-import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
+import org.togetherjava.tjbot.features.moderation.audit.ModAuditLogWriter;
+import org.togetherjava.tjbot.features.moderation.modmail.ModMailCommand;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
-import java.awt.*;
+import java.awt.Color;
import java.util.List;
import java.util.Locale;
import java.util.function.UnaryOperator;
-import java.util.regex.Pattern;
/**
* Reacts to blacklisted attachments being posted, upon which they are deleted.
@@ -35,7 +34,6 @@ public final class BlacklistedAttachmentListener extends MessageReceiverAdapter
* @param modAuditLogWriter to inform the mods about the suspicious attachment
*/
public BlacklistedAttachmentListener(Config config, ModAuditLogWriter modAuditLogWriter) {
- super(Pattern.compile(".*"));
this.modAuditLogWriter = modAuditLogWriter;
blacklistedFileExtensions = config.getBlacklistedFileExtensions();
}
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/attachment/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/package-info.java
similarity index 74%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/attachment/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/package-info.java
index 9fb7d29f53..3458f171db 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/attachment/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/package-info.java
@@ -1,11 +1,11 @@
/**
* This packages offers all the functionality for checking attachment safety see
- * {@link org.togetherjava.tjbot.commands.moderation.attachment.BlacklistedAttachmentListener
+ * {@link org.togetherjava.tjbot.features.moderation.attachment.BlacklistedAttachmentListener
* BlacklistedAttachmentListener} as main entry point.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.moderation.attachment;
+package org.togetherjava.tjbot.features.moderation.attachment;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/AuditCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/AuditCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java
index d490713b2d..b337d51b71 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/AuditCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation.audit;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
@@ -19,9 +19,13 @@
import net.dv8tion.jda.api.utils.messages.MessageRequest;
import net.dv8tion.jda.internal.requests.CompletedRestAction;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.utils.Pagination;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.moderation.ActionRecord;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationActionsStore;
+import org.togetherjava.tjbot.features.moderation.ModerationUtils;
+import org.togetherjava.tjbot.features.utils.Pagination;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/routines/ModAuditLogRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/ModAuditLogRoutine.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/routines/ModAuditLogRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/ModAuditLogRoutine.java
index 852cc1841d..d0b79a201a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/routines/ModAuditLogRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/ModAuditLogRoutine.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.routines;
+package org.togetherjava.tjbot.features.moderation.audit;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
@@ -19,12 +19,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
-import org.togetherjava.tjbot.commands.moderation.ModerationUtils;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.ModAuditLogGuildProcess;
-import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
+import org.togetherjava.tjbot.features.Routine;
+import org.togetherjava.tjbot.features.moderation.ModerationUtils;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/moderation/ModAuditLogWriter.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/ModAuditLogWriter.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/moderation/ModAuditLogWriter.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/ModAuditLogWriter.java
index 6a4ea569e9..b1babd84bd 100644
--- a/application/src/main/java/org/togetherjava/tjbot/moderation/ModAuditLogWriter.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/ModAuditLogWriter.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.moderation;
+package org.togetherjava.tjbot.features.moderation.audit;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/package-info.java
new file mode 100644
index 0000000000..3d33d80d6d
--- /dev/null
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/package-info.java
@@ -0,0 +1,11 @@
+/**
+ * This packages offers all the functionality for auditing moderation actions, see
+ * {@link org.togetherjava.tjbot.features.moderation.audit.AuditCommand} as main entry point.
+ */
+@MethodsReturnNonnullByDefault
+@ParametersAreNonnullByDefault
+package org.togetherjava.tjbot.features.moderation.audit;
+
+import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java
index 8f03496fd8..774bc2e62c 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/ModMailCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.modmail;
+package org.togetherjava.tjbot.features.moderation.modmail;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -18,10 +18,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.utils.DiscordClientAction;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.utils.DiscordClientAction;
import java.awt.*;
import java.time.Instant;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/package-info.java
similarity index 72%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/package-info.java
index d0a2de9825..dab9f5da3e 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/modmail/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/package-info.java
@@ -1,10 +1,10 @@
/**
* This packages offers all the functionality for messaging moderators trough mod mail see
- * {@link org.togetherjava.tjbot.commands.moderation.modmail.ModMailCommand} as main entry point.
+ * {@link org.togetherjava.tjbot.features.moderation.modmail.ModMailCommand} as main entry point.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.moderation.modmail;
+package org.togetherjava.tjbot.features.moderation.modmail;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/package-info.java
similarity index 85%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/package-info.java
index 56ce69483b..7e53c70a1f 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/package-info.java
@@ -4,7 +4,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.moderation;
+package org.togetherjava.tjbot.features.moderation;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamBlocker.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamBlocker.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java
index d38584ddf0..c7beafb704 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamBlocker.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.scam;
+package org.togetherjava.tjbot.features.moderation.scam;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
@@ -19,18 +19,18 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
-import org.togetherjava.tjbot.commands.UserInteractionType;
-import org.togetherjava.tjbot.commands.UserInteractor;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdInteractor;
-import org.togetherjava.tjbot.commands.moderation.ModerationAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationActionsStore;
-import org.togetherjava.tjbot.commands.moderation.ModerationUtils;
-import org.togetherjava.tjbot.commands.moderation.modmail.ModMailCommand;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.ScamBlockerConfig;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
+import org.togetherjava.tjbot.features.UserInteractionType;
+import org.togetherjava.tjbot.features.UserInteractor;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationActionsStore;
+import org.togetherjava.tjbot.features.moderation.ModerationUtils;
+import org.togetherjava.tjbot.features.moderation.modmail.ModMailCommand;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import org.togetherjava.tjbot.logging.LogMarkers;
import java.awt.Color;
@@ -74,8 +74,6 @@ public final class ScamBlocker extends MessageReceiverAdapter implements UserInt
*/
public ScamBlocker(ModerationActionsStore actionsStore, ScamHistoryStore scamHistoryStore,
Config config) {
- super(Pattern.compile(".*"));
-
this.actionsStore = actionsStore;
this.scamHistoryStore = scamHistoryStore;
this.config = config;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamDetector.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamDetector.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamDetector.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamDetector.java
index f0203588b6..a3c7061c75 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamDetector.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamDetector.java
@@ -1,8 +1,8 @@
-package org.togetherjava.tjbot.commands.moderation.scam;
+package org.togetherjava.tjbot.features.moderation.scam;
-import org.togetherjava.tjbot.commands.utils.StringDistances;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.ScamBlockerConfig;
+import org.togetherjava.tjbot.features.utils.StringDistances;
import java.net.URI;
import java.util.Locale;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamHistoryPurgeRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamHistoryPurgeRoutine.java
similarity index 90%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamHistoryPurgeRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamHistoryPurgeRoutine.java
index 848c65ad52..c6cca3c726 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamHistoryPurgeRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamHistoryPurgeRoutine.java
@@ -1,8 +1,8 @@
-package org.togetherjava.tjbot.commands.moderation.scam;
+package org.togetherjava.tjbot.features.moderation.scam;
import net.dv8tion.jda.api.JDA;
-import org.togetherjava.tjbot.commands.Routine;
+import org.togetherjava.tjbot.features.Routine;
import java.time.Instant;
import java.time.Period;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamHistoryStore.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamHistoryStore.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamHistoryStore.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamHistoryStore.java
index 1c1fcf8b4d..3348d4ee5b 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamHistoryStore.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamHistoryStore.java
@@ -1,11 +1,11 @@
-package org.togetherjava.tjbot.commands.moderation.scam;
+package org.togetherjava.tjbot.features.moderation.scam;
import net.dv8tion.jda.api.entities.Message;
import org.jooq.Result;
-import org.togetherjava.tjbot.commands.utils.Hashing;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.records.ScamHistoryRecord;
+import org.togetherjava.tjbot.features.utils.Hashing;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/package-info.java
similarity index 73%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/package-info.java
index 77bb00fedd..53849d0f58 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/package-info.java
@@ -1,10 +1,10 @@
/**
* This package offers classes dealing with detecting scam messages and taking appropriate action,
- * see {@link org.togetherjava.tjbot.commands.moderation.scam.ScamBlocker} as main entry point.
+ * see {@link org.togetherjava.tjbot.features.moderation.scam.ScamBlocker} as main entry point.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.moderation.scam;
+package org.togetherjava.tjbot.features.moderation.scam;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableModerationAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableModerationAction.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableModerationAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableModerationAction.java
index 8564289f7b..8e2774895f 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableModerationAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableModerationAction.java
@@ -1,10 +1,10 @@
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.requests.RestAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
/**
* Represents revocable moderation actions, such as temporary bans. Primarily used by
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableRoleBasedAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableRoleBasedAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java
index 645b4e1c48..c3fbb30efb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/RevocableRoleBasedAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import org.slf4j.Logger;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryBanAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryBanAction.java
similarity index 92%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryBanAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryBanAction.java
index 70b97aa856..36b2a80617 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryBanAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryBanAction.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
@@ -8,12 +8,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
import org.togetherjava.tjbot.logging.LogMarkers;
/**
* Action to revoke temporary bans, as applied by
- * {@link org.togetherjava.tjbot.commands.moderation.BanCommand} and executed by
+ * {@link org.togetherjava.tjbot.features.moderation.BanCommand} and executed by
* {@link TemporaryModerationRoutine}.
*/
final class TemporaryBanAction implements RevocableModerationAction {
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryModerationRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryModerationRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java
index a8efc75bed..4ba0f85967 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryModerationRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
@@ -7,11 +7,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
-import org.togetherjava.tjbot.commands.moderation.ActionRecord;
-import org.togetherjava.tjbot.commands.moderation.ModerationAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationActionsStore;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.Routine;
+import org.togetherjava.tjbot.features.moderation.ActionRecord;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationActionsStore;
+import org.togetherjava.tjbot.features.moderation.audit.AuditCommand;
import org.togetherjava.tjbot.logging.LogMarkers;
import java.util.Map;
@@ -27,8 +28,7 @@
* {@link ModerationActionsStore}.
*
* Revoked actions are compatible with {@link ModerationActionsStore} and commands such as
- * {@link org.togetherjava.tjbot.commands.moderation.UnbanCommand} and
- * {@link org.togetherjava.tjbot.commands.moderation.AuditCommand}.
+ * {@link org.togetherjava.tjbot.features.moderation.UnbanCommand} and {@link AuditCommand}.
*/
public final class TemporaryModerationRoutine implements Routine {
private static final Logger logger = LoggerFactory.getLogger(TemporaryModerationRoutine.class);
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryMuteAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryMuteAction.java
similarity index 81%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryMuteAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryMuteAction.java
index 120ede80a7..50c7830229 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryMuteAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryMuteAction.java
@@ -1,16 +1,16 @@
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.requests.RestAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationUtils;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationUtils;
/**
* Action to revoke temporary mutes, as applied by
- * {@link org.togetherjava.tjbot.commands.moderation.MuteCommand} and executed by
+ * {@link org.togetherjava.tjbot.features.moderation.MuteCommand} and executed by
* {@link TemporaryModerationRoutine}.
*/
final class TemporaryMuteAction extends RevocableRoleBasedAction {
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryQuarantineAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryQuarantineAction.java
similarity index 82%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryQuarantineAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryQuarantineAction.java
index cceee38592..156f3915ce 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryQuarantineAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryQuarantineAction.java
@@ -1,16 +1,16 @@
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.requests.RestAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationAction;
-import org.togetherjava.tjbot.commands.moderation.ModerationUtils;
import org.togetherjava.tjbot.config.Config;
+import org.togetherjava.tjbot.features.moderation.ModerationAction;
+import org.togetherjava.tjbot.features.moderation.ModerationUtils;
/**
* Action to revoke temporary quarantines, as applied by
- * {@link org.togetherjava.tjbot.commands.moderation.QuarantineCommand} and executed by
+ * {@link org.togetherjava.tjbot.features.moderation.QuarantineCommand} and executed by
* {@link TemporaryModerationRoutine}.
*/
final class TemporaryQuarantineAction extends RevocableRoleBasedAction {
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/package-info.java
similarity index 83%
rename from application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/package-info.java
index bb89723144..530d0150d5 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/package-info.java
@@ -3,7 +3,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.moderation.temp;
+package org.togetherjava.tjbot.features.moderation.temp;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/package-info.java
similarity index 56%
rename from application/src/main/java/org/togetherjava/tjbot/commands/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/package-info.java
index 0029166d7e..fdd9d2c718 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/package-info.java
@@ -2,16 +2,16 @@
* This package contains the command system and most commands of the bot. Commands can also be
* created in different modules, if desired.
*
- * Commands are registered in {@link org.togetherjava.tjbot.commands.Features} and then picked up by
- * the {@link org.togetherjava.tjbot.commands.system.BotCore}.
+ * Commands are registered in {@link org.togetherjava.tjbot.features.Features} and then picked up by
+ * the {@link org.togetherjava.tjbot.features.system.BotCore}.
*
* Custom slash commands can be created by implementing
- * {@link org.togetherjava.tjbot.commands.SlashCommand} or using the adapter
- * {@link org.togetherjava.tjbot.commands.SlashCommandAdapter} for convenience.
+ * {@link org.togetherjava.tjbot.features.SlashCommand} or using the adapter
+ * {@link org.togetherjava.tjbot.features.SlashCommandAdapter} for convenience.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/reminder/RemindRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/reminder/RemindRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java
index b5bedd5906..900e7792b6 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/reminder/RemindRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.reminder;
+package org.togetherjava.tjbot.features.reminder;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
@@ -11,8 +11,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.Routine;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/reminder/ReminderCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java
similarity index 84%
rename from application/src/main/java/org/togetherjava/tjbot/commands/reminder/ReminderCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java
index a0bb1ee9a3..273e832988 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/reminder/ReminderCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.reminder;
+package org.togetherjava.tjbot.features.reminder;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
@@ -7,9 +7,12 @@
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.entities.emoji.EmojiUnion;
+import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
+import net.dv8tion.jda.api.interactions.AutoCompleteQuery;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
+import net.dv8tion.jda.api.interactions.commands.Command;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
@@ -20,12 +23,13 @@
import net.dv8tion.jda.api.utils.messages.MessageEditData;
import org.jooq.Result;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
-import org.togetherjava.tjbot.commands.utils.Pagination;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.records.PendingRemindersRecord;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
+import org.togetherjava.tjbot.features.utils.Pagination;
+import org.togetherjava.tjbot.features.utils.StringDistances;
import java.time.*;
import java.time.temporal.TemporalAmount;
@@ -54,6 +58,8 @@
public final class ReminderCommand extends SlashCommandAdapter {
private static final String COMMAND_NAME = "reminder";
private static final String LIST_SUBCOMMAND = "list";
+ private static final String CANCEL_COMMAND = "cancel";
+ private static final String CANCEL_REMINDER_OPTION = "reminder";
static final String CREATE_SUBCOMMAND = "create";
static final String TIME_AMOUNT_OPTION = "time-amount";
static final String TIME_UNIT_OPTION = "time-unit";
@@ -94,6 +100,9 @@ public ReminderCommand(Database database) {
getData().addSubcommands(
new SubcommandData(CREATE_SUBCOMMAND, "creates a reminder").addOptions(timeAmount,
timeUnit, content),
+ new SubcommandData(CANCEL_COMMAND, "cancels a pending reminder").addOption(
+ OptionType.STRING, CANCEL_REMINDER_OPTION, "reminder to cancel", true,
+ true),
new SubcommandData(LIST_SUBCOMMAND, "shows all your currently pending reminders"));
this.database = database;
@@ -103,6 +112,7 @@ public ReminderCommand(Database database) {
public void onSlashCommand(SlashCommandInteractionEvent event) {
switch (event.getSubcommandName()) {
case CREATE_SUBCOMMAND -> handleCreateCommand(event);
+ case CANCEL_COMMAND -> handleCancelCommand(event);
case LIST_SUBCOMMAND -> handleListCommand(event);
default -> throw new AssertionError(
"Unexpected Subcommand: " + event.getSubcommandName());
@@ -127,6 +137,25 @@ public void onButtonClick(ButtonInteractionEvent event, List args) {
event.editMessage(MessageEditData.fromCreateData(message)).queue();
}
+ @Override
+ public void onAutoComplete(CommandAutoCompleteInteractionEvent event) {
+ AutoCompleteQuery focusedOption = event.getFocusedOption();
+
+ if (!focusedOption.getName().equals(CANCEL_REMINDER_OPTION)) {
+ throw new AssertionError("Unexpected option, was : " + focusedOption.getName());
+ }
+
+ List pendingReminders = getPendingReminders(event.getGuild(), event.getUser())
+ .map(PendingRemindersRecord::getContent);
+ List choices = StringDistances
+ .closeMatches(focusedOption.getValue(), pendingReminders, REMINDERS_PER_PAGE)
+ .stream()
+ .map(content -> new Command.Choice(content, content))
+ .toList();
+
+ event.replyChoices(choices).queue();
+ }
+
private void handleCreateCommand(SlashCommandInteractionEvent event) {
int timeAmount = Math.toIntExact(event.getOption(TIME_AMOUNT_OPTION).getAsLong());
String timeUnit = event.getOption(TIME_UNIT_OPTION).getAsString();
@@ -157,6 +186,17 @@ private void handleCreateCommand(SlashCommandInteractionEvent event) {
.insert());
}
+ private void handleCancelCommand(SlashCommandInteractionEvent event) {
+ String content = event.getOption(CANCEL_REMINDER_OPTION).getAsString();
+
+ database.write(context -> context.delete(PENDING_REMINDERS)
+ .where(PENDING_REMINDERS.CONTENT.eq(content)
+ .and(PENDING_REMINDERS.AUTHOR_ID.eq(event.getUser().getIdLong())))
+ .execute());
+
+ event.reply("Your reminder is canceled").setEphemeral(true).queue();
+ }
+
private void handleListCommand(SlashCommandInteractionEvent event) {
Result pendingReminders =
getPendingReminders(event.getGuild(), event.getUser());
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/reminder/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/reminder/package-info.java
similarity index 71%
rename from application/src/main/java/org/togetherjava/tjbot/commands/reminder/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/reminder/package-info.java
index 482666ae56..07bae61ce1 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/reminder/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/reminder/package-info.java
@@ -1,10 +1,10 @@
/**
* This packages offers all the functionality for the remind-command. The core class is
- * {@link org.togetherjava.tjbot.commands.reminder.ReminderCommand}.
+ * {@link org.togetherjava.tjbot.features.reminder.ReminderCommand}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.reminder;
+package org.togetherjava.tjbot.features.reminder;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/system/BotCore.java b/application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/system/BotCore.java
rename to application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java
index 90305621f1..efa539db49 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/system/BotCore.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.system;
+package org.togetherjava.tjbot.features.system;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.channel.Channel;
@@ -19,13 +19,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.*;
-import org.togetherjava.tjbot.commands.componentids.ComponentId;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdParser;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdStore;
-import org.togetherjava.tjbot.commands.componentids.InvalidComponentIdFormatException;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.*;
+import org.togetherjava.tjbot.features.componentids.ComponentId;
+import org.togetherjava.tjbot.features.componentids.ComponentIdParser;
+import org.togetherjava.tjbot.features.componentids.ComponentIdStore;
+import org.togetherjava.tjbot.features.componentids.InvalidComponentIdFormatException;
import java.util.*;
import java.util.concurrent.ExecutorService;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/system/CommandProvider.java b/application/src/main/java/org/togetherjava/tjbot/features/system/CommandProvider.java
similarity index 80%
rename from application/src/main/java/org/togetherjava/tjbot/commands/system/CommandProvider.java
rename to application/src/main/java/org/togetherjava/tjbot/features/system/CommandProvider.java
index 7446d335fa..14ded253bb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/system/CommandProvider.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/system/CommandProvider.java
@@ -1,7 +1,7 @@
-package org.togetherjava.tjbot.commands.system;
+package org.togetherjava.tjbot.features.system;
-import org.togetherjava.tjbot.commands.BotCommand;
-import org.togetherjava.tjbot.commands.UserInteractor;
+import org.togetherjava.tjbot.features.BotCommand;
+import org.togetherjava.tjbot.features.UserInteractor;
import java.util.Collection;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/system/LogLevelCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/system/LogLevelCommand.java
similarity index 92%
rename from application/src/main/java/org/togetherjava/tjbot/commands/system/LogLevelCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/system/LogLevelCommand.java
index b4ff600a1d..cc4f7e7317 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/system/LogLevelCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/system/LogLevelCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.system;
+package org.togetherjava.tjbot.features.system;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
@@ -7,8 +7,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import java.util.stream.Stream;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/system/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/system/package-info.java
similarity index 72%
rename from application/src/main/java/org/togetherjava/tjbot/commands/system/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/system/package-info.java
index 92087eae83..3d3e97d32d 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/system/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/system/package-info.java
@@ -1,10 +1,10 @@
/**
* This package represents the core of the command system. The entry point is
- * {@link org.togetherjava.tjbot.commands.system.BotCore}.
+ * {@link org.togetherjava.tjbot.features.system.BotCore}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.system;
+package org.togetherjava.tjbot.features.system;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagCommand.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tags/TagCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tags/TagCommand.java
index 679b4101e7..b9c5d76aa9 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
@@ -16,11 +16,11 @@
import net.dv8tion.jda.api.utils.FileUpload;
import net.dv8tion.jda.api.utils.messages.MessageEditBuilder;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.utils.LinkPreview;
-import org.togetherjava.tjbot.commands.utils.LinkPreviews;
-import org.togetherjava.tjbot.commands.utils.StringDistances;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.utils.LinkPreview;
+import org.togetherjava.tjbot.features.utils.LinkPreviews;
+import org.togetherjava.tjbot.features.utils.StringDistances;
import java.time.Instant;
import java.util.*;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagContentStyle.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagContentStyle.java
similarity index 91%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tags/TagContentStyle.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tags/TagContentStyle.java
index 898576a394..fa2751e6c4 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagContentStyle.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagContentStyle.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
/**
* The style of a tag content.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagManageCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tags/TagManageCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java
index 385d60b990..8d957fedfb 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagManageCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
@@ -14,9 +14,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.moderation.audit.ModAuditLogWriter;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagSystem.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagSystem.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tags/TagSystem.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tags/TagSystem.java
index 96c70a8d61..f335f97d7c 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagSystem.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagSystem.java
@@ -1,14 +1,14 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
-import org.togetherjava.tjbot.commands.utils.StringDistances;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.Tags;
import org.togetherjava.tjbot.db.generated.tables.records.TagsRecord;
+import org.togetherjava.tjbot.features.utils.StringDistances;
import java.awt.Color;
import java.util.Optional;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagsCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagsCommand.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tags/TagsCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tags/TagsCommand.java
index 1a425eab2d..cfd04d856a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tags/TagsCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagsCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
@@ -7,8 +7,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
import java.time.Instant;
import java.util.Collection;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tags/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/package-info.java
similarity index 66%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tags/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tags/package-info.java
index 674fd1fce4..e4b44e16cc 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tags/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/package-info.java
@@ -1,12 +1,12 @@
/**
* This package offers the tag system and its commands. See
- * {@link org.togetherjava.tjbot.commands.tags.TagSystem} for the core of the system and commands
- * like {@link org.togetherjava.tjbot.commands.tags.TagCommand} as entry point to the package's
+ * {@link org.togetherjava.tjbot.features.tags.TagSystem} for the core of the system and commands
+ * like {@link org.togetherjava.tjbot.features.tags.TagCommand} as entry point to the package's
* offered functionality.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersCommand.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java
index 27dc57ee6d..52692f139b 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersCommand.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tophelper;
+package org.togetherjava.tjbot.features.tophelper;
import com.github.freva.asciitable.AsciiTable;
import com.github.freva.asciitable.Column;
@@ -15,10 +15,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.CommandVisibility;
-import org.togetherjava.tjbot.commands.SlashCommandAdapter;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.CommandVisibility;
+import org.togetherjava.tjbot.features.SlashCommandAdapter;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersMessageListener.java b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersMessageListener.java
similarity index 95%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersMessageListener.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersMessageListener.java
index b781760d92..9d98014aa4 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersMessageListener.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersMessageListener.java
@@ -1,13 +1,13 @@
-package org.togetherjava.tjbot.commands.tophelper;
+package org.togetherjava.tjbot.features.tophelper;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
-import org.togetherjava.tjbot.commands.MessageReceiverAdapter;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.MessageReceiverAdapter;
import java.util.function.Predicate;
import java.util.regex.Pattern;
@@ -38,8 +38,6 @@ public final class TopHelpersMessageListener extends MessageReceiverAdapter {
* @param config the config to use for this
*/
public TopHelpersMessageListener(Database database, Config config) {
- super(Pattern.compile(".*"));
-
this.database = database;
isHelpForumName =
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersPurgeMessagesRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersPurgeMessagesRoutine.java
similarity index 94%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersPurgeMessagesRoutine.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersPurgeMessagesRoutine.java
index d99924ddce..d768a66587 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/TopHelpersPurgeMessagesRoutine.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersPurgeMessagesRoutine.java
@@ -1,11 +1,11 @@
-package org.togetherjava.tjbot.commands.tophelper;
+package org.togetherjava.tjbot.features.tophelper;
import net.dv8tion.jda.api.JDA;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.Routine;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.Routine;
import java.time.Instant;
import java.time.Period;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/package-info.java
similarity index 72%
rename from application/src/main/java/org/togetherjava/tjbot/commands/tophelper/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/tophelper/package-info.java
index 042aef8901..3f8aa7dff5 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/tophelper/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/package-info.java
@@ -1,10 +1,10 @@
/**
* This packages offers all the functionality for the top-helpers command system. The core class is
- * {@link org.togetherjava.tjbot.commands.tophelper.TopHelpersCommand}.
+ * {@link org.togetherjava.tjbot.features.tophelper.TopHelpersCommand}.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.tophelper;
+package org.togetherjava.tjbot.features.tophelper;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/CodeFence.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/CodeFence.java
similarity index 92%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/CodeFence.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/CodeFence.java
index 41b219160d..dc907f9ede 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/CodeFence.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/CodeFence.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import javax.annotation.Nullable;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/DiscordClientAction.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/DiscordClientAction.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/DiscordClientAction.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/DiscordClientAction.java
index a1dba61977..da4028f656 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/DiscordClientAction.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/DiscordClientAction.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/Hashing.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/Hashing.java
similarity index 97%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/Hashing.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/Hashing.java
index 2551259e6b..245f942783 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/Hashing.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/Hashing.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/LinkPreview.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreview.java
similarity index 98%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/LinkPreview.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreview.java
index e6a0e66509..7b878782b5 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/LinkPreview.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreview.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/LinkPreviews.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/LinkPreviews.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java
index 57261f82bb..f5bbb5f353 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/LinkPreviews.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import com.linkedin.urls.Url;
import com.linkedin.urls.detection.UrlDetector;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/MessageUtils.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/MessageUtils.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/MessageUtils.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/MessageUtils.java
index 36939cc097..b5fe69dccf 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/MessageUtils.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/MessageUtils.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/Pagination.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/Pagination.java
similarity index 93%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/Pagination.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/Pagination.java
index d9871e6ac8..3fdc2d41d3 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/Pagination.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/Pagination.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
/**
* Utility for pagination.
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/StringDistances.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/StringDistances.java
similarity index 99%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/StringDistances.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/StringDistances.java
index 87208e8335..583623cae2 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/StringDistances.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/StringDistances.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import java.util.*;
import java.util.stream.IntStream;
diff --git a/application/src/main/java/org/togetherjava/tjbot/commands/utils/package-info.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/package-info.java
similarity index 84%
rename from application/src/main/java/org/togetherjava/tjbot/commands/utils/package-info.java
rename to application/src/main/java/org/togetherjava/tjbot/features/utils/package-info.java
index be1f45fd42..35f7961773 100644
--- a/application/src/main/java/org/togetherjava/tjbot/commands/utils/package-info.java
+++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/package-info.java
@@ -3,7 +3,7 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java
index ac13027b4e..ece1a49a5a 100644
--- a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java
+++ b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java
@@ -10,7 +10,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.togetherjava.tjbot.commands.utils.MessageUtils;
+import org.togetherjava.tjbot.features.utils.MessageUtils;
import org.togetherjava.tjbot.logging.LogMarkers;
import java.io.PrintWriter;
diff --git a/application/src/main/java/org/togetherjava/tjbot/moderation/package-info.java b/application/src/main/java/org/togetherjava/tjbot/moderation/package-info.java
deleted file mode 100644
index 0145c5cdac..0000000000
--- a/application/src/main/java/org/togetherjava/tjbot/moderation/package-info.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * This packages offers all the functionality revolving around moderation.
- */
-@MethodsReturnNonnullByDefault
-@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.moderation;
-
-import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/application/src/main/java/org/togetherjava/tjbot/routines/package-info.java b/application/src/main/java/org/togetherjava/tjbot/routines/package-info.java
deleted file mode 100644
index f3f1ca00cd..0000000000
--- a/application/src/main/java/org/togetherjava/tjbot/routines/package-info.java
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * This package contains most routines of the bot. Routines can also be created in different
- * modules, if desired.
- *
- * Routines are actions that are executed periodically on a schedule. They are added to the system
- * in {@link org.togetherjava.tjbot.commands.Features}.
- */
-@MethodsReturnNonnullByDefault
-@ParametersAreNonnullByDefault
-package org.togetherjava.tjbot.routines;
-
-import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/application/src/main/resources/slashCommandPopupAdvice.png b/application/src/main/resources/slashCommandPopupAdvice.png
new file mode 100644
index 0000000000..6284b8566e
Binary files /dev/null and b/application/src/main/resources/slashCommandPopupAdvice.png differ
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/SlashCommandAdapterTest.java b/application/src/test/java/org/togetherjava/tjbot/features/SlashCommandAdapterTest.java
similarity index 97%
rename from application/src/test/java/org/togetherjava/tjbot/commands/SlashCommandAdapterTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/SlashCommandAdapterTest.java
index 7af10a1861..745731031b 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/SlashCommandAdapterTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/SlashCommandAdapterTest.java
@@ -1,10 +1,10 @@
-package org.togetherjava.tjbot.commands;
+package org.togetherjava.tjbot.features;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
import org.junit.jupiter.api.Test;
-import org.togetherjava.tjbot.commands.componentids.Lifespan;
+import org.togetherjava.tjbot.features.componentids.Lifespan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/basic/PingCommandTest.java b/application/src/test/java/org/togetherjava/tjbot/features/basic/PingCommandTest.java
similarity index 91%
rename from application/src/test/java/org/togetherjava/tjbot/commands/basic/PingCommandTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/basic/PingCommandTest.java
index a2f4d14a01..fe82957c21 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/basic/PingCommandTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/basic/PingCommandTest.java
@@ -1,11 +1,11 @@
-package org.togetherjava.tjbot.commands.basic;
+package org.togetherjava.tjbot.features.basic;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
-import org.togetherjava.tjbot.commands.SlashCommand;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.jda.JdaTester;
import static org.mockito.Mockito.verify;
diff --git a/application/src/test/java/org/togetherjava/tjbot/features/basic/SlashCommandEducatorTest.java b/application/src/test/java/org/togetherjava/tjbot/features/basic/SlashCommandEducatorTest.java
new file mode 100644
index 0000000000..6e118a5c76
--- /dev/null
+++ b/application/src/test/java/org/togetherjava/tjbot/features/basic/SlashCommandEducatorTest.java
@@ -0,0 +1,70 @@
+package org.togetherjava.tjbot.features.basic;
+
+import net.dv8tion.jda.api.entities.MessageEmbed;
+import net.dv8tion.jda.api.entities.channel.ChannelType;
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
+import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
+import net.dv8tion.jda.api.utils.messages.MessageCreateData;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import org.togetherjava.tjbot.features.MessageReceiver;
+import org.togetherjava.tjbot.jda.JdaTester;
+
+import java.util.List;
+import java.util.stream.Stream;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+final class SlashCommandEducatorTest {
+ private JdaTester jdaTester;
+ private MessageReceiver messageReceiver;
+
+ @BeforeEach
+ void setUp() {
+ jdaTester = new JdaTester();
+ messageReceiver = new SlashCommandEducator();
+ }
+
+ private MessageReceivedEvent sendMessage(String content) {
+ MessageCreateData message = new MessageCreateBuilder().setContent(content).build();
+ MessageReceivedEvent event =
+ jdaTester.createMessageReceiveEvent(message, List.of(), ChannelType.TEXT);
+
+ messageReceiver.onMessageReceived(event);
+
+ return event;
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideMessageCommands")
+ void sendsAdviceOnMessageCommand(String message) {
+ // GIVEN a message containing a message command
+ // WHEN the message is sent
+ MessageReceivedEvent event = sendMessage(message);
+
+ // THEN the system replies to it with an advice
+ verify(event.getMessage(), times(1)).replyEmbeds(any(MessageEmbed.class));
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideOtherMessages")
+ void ignoresOtherMessages(String message) {
+ // GIVEN a message that is not a message command
+ // WHEN the message is sent
+ MessageReceivedEvent event = sendMessage(message);
+
+ // THEN the system ignores the message and does not reply to it
+ verify(event.getMessage(), never()).replyEmbeds(any(MessageEmbed.class));
+ }
+
+ private static Stream provideMessageCommands() {
+ return Stream.of("!foo", ".foo", "?foo", ".test", "!whatever", "!this is a test");
+ }
+
+ private static Stream provideOtherMessages() {
+ return Stream.of(" a ", "foo", "#foo", "/foo", "!!!", "?!?!?", "?", ".,-", "!f", "! foo");
+ }
+}
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommandTest.java b/application/src/test/java/org/togetherjava/tjbot/features/mathcommands/TeXCommandTest.java
similarity index 97%
rename from application/src/test/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommandTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/mathcommands/TeXCommandTest.java
index 2e591d256f..4ba05958b2 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommandTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/mathcommands/TeXCommandTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mathcommands;
+package org.togetherjava.tjbot.features.mathcommands;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.utils.FileUpload;
@@ -8,7 +8,7 @@
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.ArgumentMatcher;
-import org.togetherjava.tjbot.commands.SlashCommand;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.jda.JdaTester;
import java.util.ArrayList;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/mediaonly/MediaOnlyChannelListenerTest.java b/application/src/test/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListenerTest.java
similarity index 98%
rename from application/src/test/java/org/togetherjava/tjbot/commands/mediaonly/MediaOnlyChannelListenerTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListenerTest.java
index fa5f3476ea..fcc9f8b71b 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/mediaonly/MediaOnlyChannelListenerTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListenerTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.mediaonly;
+package org.togetherjava.tjbot.features.mediaonly;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/moderation/scam/ScamDetectorTest.java b/application/src/test/java/org/togetherjava/tjbot/features/moderation/scam/ScamDetectorTest.java
similarity index 99%
rename from application/src/test/java/org/togetherjava/tjbot/commands/moderation/scam/ScamDetectorTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/moderation/scam/ScamDetectorTest.java
index 3208ff8079..b9218b368a 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/moderation/scam/ScamDetectorTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/moderation/scam/ScamDetectorTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.moderation.scam;
+package org.togetherjava.tjbot.features.moderation.scam;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/reminder/RawReminderTestHelper.java b/application/src/test/java/org/togetherjava/tjbot/features/reminder/RawReminderTestHelper.java
similarity index 97%
rename from application/src/test/java/org/togetherjava/tjbot/commands/reminder/RawReminderTestHelper.java
rename to application/src/test/java/org/togetherjava/tjbot/features/reminder/RawReminderTestHelper.java
index 68e9657cfb..00ccfd09fe 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/reminder/RawReminderTestHelper.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/reminder/RawReminderTestHelper.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.reminder;
+package org.togetherjava.tjbot.features.reminder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/reminder/RemindRoutineTest.java b/application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java
similarity index 98%
rename from application/src/test/java/org/togetherjava/tjbot/commands/reminder/RemindRoutineTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java
index 55d0a00f7f..f4469c3e89 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/reminder/RemindRoutineTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.reminder;
+package org.togetherjava.tjbot.features.reminder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.MessageEmbed;
@@ -14,8 +14,8 @@
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
-import org.togetherjava.tjbot.commands.Routine;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.Routine;
import org.togetherjava.tjbot.jda.JdaTester;
import java.time.Instant;
@@ -184,6 +184,6 @@ void reminderIsNotSendIfNotPending() {
private static void assertSimilar(Instant expected, Instant actual) {
// NOTE For some reason, the instant ends up in the database slightly wrong already (about
// half a second), seems to be an issue with jOOQ
- assertEquals(expected.toEpochMilli(), actual.toEpochMilli(), TimeUnit.SECONDS.toMillis(1));
+ assertEquals(expected.toEpochMilli(), actual.toEpochMilli(), TimeUnit.SECONDS.toMillis(2));
}
}
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/reminder/ReminderCommandTest.java b/application/src/test/java/org/togetherjava/tjbot/features/reminder/ReminderCommandTest.java
similarity index 98%
rename from application/src/test/java/org/togetherjava/tjbot/commands/reminder/ReminderCommandTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/reminder/ReminderCommandTest.java
index a628b1042a..9ce493ede0 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/reminder/ReminderCommandTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/reminder/ReminderCommandTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.reminder;
+package org.togetherjava.tjbot.features.reminder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -8,8 +8,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
-import org.togetherjava.tjbot.commands.SlashCommand;
import org.togetherjava.tjbot.db.Database;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.jda.JdaTester;
import java.time.Instant;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/system/ComponentIdTest.java b/application/src/test/java/org/togetherjava/tjbot/features/system/ComponentIdTest.java
similarity index 85%
rename from application/src/test/java/org/togetherjava/tjbot/commands/system/ComponentIdTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/system/ComponentIdTest.java
index 19f3aa7cf5..ca5419a8fe 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/system/ComponentIdTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/system/ComponentIdTest.java
@@ -1,8 +1,8 @@
-package org.togetherjava.tjbot.commands.system;
+package org.togetherjava.tjbot.features.system;
import org.junit.jupiter.api.Test;
-import org.togetherjava.tjbot.commands.componentids.ComponentId;
+import org.togetherjava.tjbot.features.componentids.ComponentId;
import java.util.List;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagCommandTest.java b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagCommandTest.java
similarity index 97%
rename from application/src/test/java/org/togetherjava/tjbot/commands/tags/TagCommandTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/tags/TagCommandTest.java
index d0bf5f99e9..bdd119a311 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagCommandTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagCommandTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.MessageEmbed;
@@ -7,9 +7,9 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
-import org.togetherjava.tjbot.commands.SlashCommand;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.Tags;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.jda.JdaTester;
import org.togetherjava.tjbot.jda.SlashCommandInteractionEventBuilder;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagManageCommandTest.java b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagManageCommandTest.java
similarity index 99%
rename from application/src/test/java/org/togetherjava/tjbot/commands/tags/TagManageCommandTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/tags/TagManageCommandTest.java
index fca926c906..8789d2b679 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagManageCommandTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagManageCommandTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
@@ -13,12 +13,12 @@
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-import org.togetherjava.tjbot.commands.SlashCommand;
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.Tags;
+import org.togetherjava.tjbot.features.SlashCommand;
+import org.togetherjava.tjbot.features.moderation.audit.ModAuditLogWriter;
import org.togetherjava.tjbot.jda.JdaTester;
-import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
import java.io.IOException;
import java.util.List;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagSystemTest.java b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagSystemTest.java
similarity index 98%
rename from application/src/test/java/org/togetherjava/tjbot/commands/tags/TagSystemTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/tags/TagSystemTest.java
index fde2316892..bd0efcc9d9 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagSystemTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagSystemTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.junit.jupiter.api.BeforeEach;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagsCommandTest.java b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagsCommandTest.java
similarity index 98%
rename from application/src/test/java/org/togetherjava/tjbot/commands/tags/TagsCommandTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/tags/TagsCommandTest.java
index 39de684ec8..9586c2b6d6 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/tags/TagsCommandTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/tags/TagsCommandTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tags;
+package org.togetherjava.tjbot.features.tags;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
@@ -10,9 +10,9 @@
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-import org.togetherjava.tjbot.commands.SlashCommand;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.Tags;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.jda.JdaTester;
import javax.annotation.Nullable;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/tophelper/TopHelperMessageListenerTest.java b/application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java
similarity index 99%
rename from application/src/test/java/org/togetherjava/tjbot/commands/tophelper/TopHelperMessageListenerTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java
index d3df4aa76c..e4cb316a6e 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/tophelper/TopHelperMessageListenerTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.tophelper;
+package org.togetherjava.tjbot.features.tophelper;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/utils/MessageUtilsTest.java b/application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java
similarity index 99%
rename from application/src/test/java/org/togetherjava/tjbot/commands/utils/MessageUtilsTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java
index 3c7bf9edfb..cfaa20a7fb 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/utils/MessageUtilsTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
diff --git a/application/src/test/java/org/togetherjava/tjbot/commands/utils/StringDistancesTest.java b/application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java
similarity index 98%
rename from application/src/test/java/org/togetherjava/tjbot/commands/utils/StringDistancesTest.java
rename to application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java
index 4a439e1f7a..6454ca2bbb 100644
--- a/application/src/test/java/org/togetherjava/tjbot/commands/utils/StringDistancesTest.java
+++ b/application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java
@@ -1,4 +1,4 @@
-package org.togetherjava.tjbot.commands.utils;
+package org.togetherjava.tjbot.features.utils;
import org.junit.jupiter.api.Test;
diff --git a/application/src/test/java/org/togetherjava/tjbot/jda/ButtonClickEventBuilder.java b/application/src/test/java/org/togetherjava/tjbot/jda/ButtonClickEventBuilder.java
index 75b1c4c435..e2e94c507c 100644
--- a/application/src/test/java/org/togetherjava/tjbot/jda/ButtonClickEventBuilder.java
+++ b/application/src/test/java/org/togetherjava/tjbot/jda/ButtonClickEventBuilder.java
@@ -10,7 +10,7 @@
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
-import org.togetherjava.tjbot.commands.SlashCommand;
+import org.togetherjava.tjbot.features.SlashCommand;
import javax.annotation.Nullable;
diff --git a/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java b/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java
index 66734c2c64..a634c93165 100644
--- a/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java
+++ b/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java
@@ -47,8 +47,8 @@
import org.mockito.MockingDetails;
import org.mockito.stubbing.Answer;
-import org.togetherjava.tjbot.commands.SlashCommand;
-import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
+import org.togetherjava.tjbot.features.SlashCommand;
+import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
import javax.annotation.Nullable;
@@ -216,6 +216,8 @@ public JdaTester() {
doNothing().when(messageCreateAction).queue();
when(messageCreateAction.setContent(any())).thenReturn(messageCreateAction);
when(messageCreateAction.addContent(any())).thenReturn(messageCreateAction);
+ when(messageCreateAction.addFiles(any(FileUpload.class))).thenReturn(messageCreateAction);
+ when(messageCreateAction.addFiles(anyCollection())).thenReturn(messageCreateAction);
CacheRestAction privateChannelAction =
createSucceededActionMock(privateChannel, CacheRestAction.class);
@@ -577,7 +579,7 @@ public ErrorResponseException createErrorResponseException(ErrorResponse reason)
/**
* Creates a Mockito mocked message receive event, which can be used for
- * {@link org.togetherjava.tjbot.commands.MessageReceiver#onMessageReceived(MessageReceivedEvent)}.
+ * {@link org.togetherjava.tjbot.features.MessageReceiver#onMessageReceived(MessageReceivedEvent)}.
*
* @param message the message that has been received
* @param attachments attachments of the message, empty if none
diff --git a/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java b/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java
index b97c9a480f..f926ecf69e 100644
--- a/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java
+++ b/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java
@@ -12,7 +12,7 @@
import net.dv8tion.jda.internal.JDAImpl;
import net.dv8tion.jda.internal.interactions.command.SlashCommandInteractionImpl;
-import org.togetherjava.tjbot.commands.SlashCommand;
+import org.togetherjava.tjbot.features.SlashCommand;
import org.togetherjava.tjbot.jda.payloads.PayloadMember;
import org.togetherjava.tjbot.jda.payloads.PayloadUser;
import org.togetherjava.tjbot.jda.payloads.slashcommand.*;
diff --git a/build.gradle b/build.gradle
index 9c45235c19..741af4896c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,8 @@
plugins {
id 'java'
- id "com.diffplug.spotless" version "6.12.0"
+ id "com.diffplug.spotless" version "6.14.0"
id "org.sonarqube" version "3.5.0.2730"
- id "name.remal.sonarlint" version "2.1.0"
+ id "name.remal.sonarlint" version "3.0.0"
}
group 'org.togetherjava'
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 0771553880..b2e5c5179d 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -7,6 +7,6 @@ repositories {
}
dependencies {
- implementation "gradle.plugin.org.flywaydb:gradle-plugin-publishing:9.11.0"
+ implementation "gradle.plugin.org.flywaydb:gradle-plugin-publishing:9.14.0"
implementation 'nu.studer:gradle-jooq-plugin:8.1'
}
diff --git a/database/build.gradle b/database/build.gradle
index 0d74ae5cd5..d1a8c9ee6f 100644
--- a/database/build.gradle
+++ b/database/build.gradle
@@ -7,7 +7,7 @@ var sqliteVersion = "3.40.0.0"
dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation "org.xerial:sqlite-jdbc:${sqliteVersion}"
- implementation 'org.flywaydb:flyway-core:9.11.0'
+ implementation 'org.flywaydb:flyway-core:9.14.0'
implementation "org.jooq:jooq:$jooqVersion"
implementation project(':utils')
diff --git a/formatter/src/test/java/org/togetherjava/tjbot/formatter/FormatterTest.java b/formatter/src/test/java/org/togetherjava/tjbot/formatter/FormatterTest.java
index 5c78480270..efc5622dec 100644
--- a/formatter/src/test/java/org/togetherjava/tjbot/formatter/FormatterTest.java
+++ b/formatter/src/test/java/org/togetherjava/tjbot/formatter/FormatterTest.java
@@ -105,11 +105,11 @@ void foo() {
Arguments.of("right shifts", "x >> 1, y >>> 1", "x >> 1, y >>> 1"),
Arguments.of("minimized real code",
"""
- package org.togetherjava.tjbot.commands.code;import com.google.common.collect.Range; \
+ package org.togetherjava.tjbot.features.code;import com.google.common.collect.Range; \
import com.google.googlejavaformat.java.FormatterException; \
import com.google.googlejavaformat.java.JavaOutput;import com.google.googlejavaformat.java.Replacement; \
import com.google.googlejavaformat.java.SnippetFormatter;import net.dv8tion.jda.api.EmbedBuilder; \
- import net.dv8tion.jda.api.entities.MessageEmbed;import org.togetherjava.tjbot.commands.utils.CodeFence; \
+ import net.dv8tion.jda.api.entities.MessageEmbed;import org.togetherjava.tjbot.features.utils.CodeFence; \
import java.util.List;final class FormatCodeCommand implements CodeAction{private final SnippetFormatter formatter \
=new SnippetFormatter();@Override
public String getLabel(){return"Format";}@Override
@@ -123,7 +123,7 @@ private String formatCode(String code){for(SnippetFormatter.SnippetKind snippetK
return JavaOutput.applyReplacements(code,replacements);}catch(FormatterException e){}}
return"nope...";}}""",
"""
- package org.togetherjava.tjbot.commands.code;
+ package org.togetherjava.tjbot.features.code;
import com.google.common.collect.Range;
import com.google.googlejavaformat.java.FormatterException;
@@ -132,7 +132,7 @@ private String formatCode(String code){for(SnippetFormatter.SnippetKind snippetK
import com.google.googlejavaformat.java.SnippetFormatter;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
- import org.togetherjava.tjbot.commands.utils.CodeFence;
+ import org.togetherjava.tjbot.features.utils.CodeFence;
import java.util.List;
final class FormatCodeCommand implements CodeAction {