Skip to content

Commit 5542289

Browse files
feat: create application form command
Co-authored-by: Suraj Kumar <[email protected]>
1 parent f4e0f73 commit 5542289

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

application/src/main/java/org/togetherjava/tjbot/features/Features.java

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.togetherjava.tjbot.features.moderation.temp.TemporaryModerationRoutine;
6565
import org.togetherjava.tjbot.features.reminder.RemindRoutine;
6666
import org.togetherjava.tjbot.features.reminder.ReminderCommand;
67+
import org.togetherjava.tjbot.features.roleapplication.ApplicationCreateCommand;
6768
import org.togetherjava.tjbot.features.system.BotCore;
6869
import org.togetherjava.tjbot.features.system.LogLevelCommand;
6970
import org.togetherjava.tjbot.features.tags.TagCommand;
@@ -192,6 +193,7 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
192193
features.add(new BookmarksCommand(bookmarksSystem));
193194
features.add(new ChatGptCommand(chatGptService, helpSystemHelper));
194195
features.add(new JShellCommand(jshellEval));
196+
features.add(new ApplicationCreateCommand(config));
195197

196198
FeatureBlacklist<Class<?>> blacklist = blacklistConfig.normal();
197199
return blacklist.filterStream(features.stream(), Object::getClass).toList();

application/src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationApplyHandler.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
1212
import net.dv8tion.jda.api.interactions.modals.ModalMapping;
1313

14-
import org.togetherjava.tjbot.config.RoleApplicationSystemConfig;
14+
import org.togetherjava.tjbot.config.ApplicationFormConfig;
1515

1616
import java.time.Duration;
1717
import java.time.Instant;
@@ -32,18 +32,18 @@ public class ApplicationApplyHandler {
3232

3333
private final Cache<Member, OffsetDateTime> applicationSubmitCooldown;
3434
private final Predicate<String> applicationChannelPattern;
35-
private final RoleApplicationSystemConfig formConfig;
35+
private final ApplicationFormConfig formConfig;
3636

3737
/**
3838
* Constructs a new {@code ApplicationApplyHandler} instance.
3939
*
4040
* @param formConfig the configuration that contains the details for the application form
4141
* including the cooldown duration and channel pattern.
4242
*/
43-
public ApplicationApplyHandler(RoleApplicationSystemConfig formConfig) {
43+
public ApplicationApplyHandler(ApplicationFormConfig formConfig) {
4444
this.formConfig = formConfig;
4545
this.applicationChannelPattern =
46-
Pattern.compile(formConfig.submissionsChannelPattern()).asMatchPredicate();
46+
Pattern.compile(formConfig.applicationChannelPattern()).asMatchPredicate();
4747

4848
final Duration applicationSubmitCooldownDuration =
4949
Duration.ofMinutes(formConfig.applicationSubmitCooldownMinutes());

application/src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationCreateCommand.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import org.slf4j.Logger;
2424
import org.slf4j.LoggerFactory;
2525

26+
import org.togetherjava.tjbot.config.ApplicationFormConfig;
2627
import org.togetherjava.tjbot.config.Config;
27-
import org.togetherjava.tjbot.config.RoleApplicationSystemConfig;
2828
import org.togetherjava.tjbot.features.CommandVisibility;
2929
import org.togetherjava.tjbot.features.SlashCommandAdapter;
3030
import org.togetherjava.tjbot.features.componentids.Lifespan;
@@ -55,7 +55,7 @@ public class ApplicationCreateCommand extends SlashCommandAdapter {
5555
private static final int ARG_COUNT = 3;
5656

5757
private final ApplicationApplyHandler applicationApplyHandler;
58-
private final RoleApplicationSystemConfig formConfig;
58+
private final ApplicationFormConfig formConfig;
5959

6060
/**
6161
* Constructs a new {@link ApplicationCreateCommand} with the specified configuration.
@@ -68,7 +68,7 @@ public ApplicationCreateCommand(Config config) {
6868
super("application-form", "Generates an application form for members to apply for roles.",
6969
CommandVisibility.GUILD);
7070

71-
this.formConfig = config.getRoleApplicationSystemConfig();
71+
this.formConfig = config.getApplicationFormConfig();
7272

7373
generateRoleOptions(getData());
7474
applicationApplyHandler = new ApplicationApplyHandler(formConfig);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* This packages offers all the functionality for the application-create command as well as the
3+
* application system. The core class is
4+
* {@link org.togetherjava.tjbot.features.roleapplication.ApplicationCreateCommand}.
5+
*/
6+
@MethodsReturnNonnullByDefault
7+
@ParametersAreNonnullByDefault
8+
package org.togetherjava.tjbot.features.roleapplication;
9+
10+
import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;
11+
12+
import javax.annotation.ParametersAreNonnullByDefault;

0 commit comments

Comments
 (0)