Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add slash command to generate application form for various community roles #1049

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
7 changes: 5 additions & 2 deletions application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
"special": [
]
},
"memberCountCategoryPattern": "Info",
"selectRolesChannelPattern": "select-your-roles"
"applicationForm": {
"applicationChannelPattern": "applications-log"
}
"selectRolesChannelPattern": "select-your-roles",
"memberCountCategoryPattern": "Info"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.togetherjava.tjbot.config;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

/**
* Represents the configuration for an application form, including roles and application channel
* pattern.
*/
public record ApplicationFormConfig(@JsonProperty(value = "applicationChannelPattern",
required = true) String applicationChannelPattern) {

/**
* Constructs an instance of {@link ApplicationFormConfig} with the provided parameters.
*
* @param applicationChannelPattern the pattern used to identify the application channel
*/
public ApplicationFormConfig {
Objects.requireNonNull(applicationChannelPattern);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.togetherjava.tjbot.config;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

/**
* Represents the configuration for applying a role.
*/
public record ApplyRoleConfig(@JsonProperty(value = "name", required = true) String name,
@JsonProperty(value = "description", required = true) String description,
@JsonProperty(value = "formattedEmoji") String emoji) {

/**
* Constructs an instance of ApplyRoleConfig with the given parameters.
*
* @param name the name of the role
* @param description the description of the role
* @param emoji the emoji associated with the role
*/
public ApplyRoleConfig {
Objects.requireNonNull(name);
Objects.requireNonNull(description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class Config {
private final FeatureBlacklistConfig featureBlacklistConfig;
private final String selectRolesChannelPattern;
private final String memberCountCategoryPattern;
private final ApplicationFormConfig applicationFormConfig;

@SuppressWarnings("ConstructorWithTooManyParameters")
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down Expand Up @@ -91,7 +92,9 @@ private Config(@JsonProperty(value = "token", required = true) String token,
@JsonProperty(value = "featureBlacklist",
required = true) FeatureBlacklistConfig featureBlacklistConfig,
@JsonProperty(value = "selectRolesChannelPattern",
required = true) String selectRolesChannelPattern) {
required = true) String selectRolesChannelPattern,
@JsonProperty(value = "applicationForm",
required = true) ApplicationFormConfig applicationFormConfig) {
this.token = Objects.requireNonNull(token);
this.githubApiKey = Objects.requireNonNull(githubApiKey);
this.databasePath = Objects.requireNonNull(databasePath);
Expand Down Expand Up @@ -123,6 +126,7 @@ private Config(@JsonProperty(value = "token", required = true) String token,
this.jshell = Objects.requireNonNull(jshell);
this.featureBlacklistConfig = Objects.requireNonNull(featureBlacklistConfig);
this.selectRolesChannelPattern = Objects.requireNonNull(selectRolesChannelPattern);
this.applicationFormConfig = applicationFormConfig;
}

/**
Expand Down Expand Up @@ -405,4 +409,13 @@ public String getSelectRolesChannelPattern() {
public String getMemberCountCategoryPattern() {
return memberCountCategoryPattern;
}

/**
* The configuration related to the application form.
*
* @return the application form config
*/
public ApplicationFormConfig getApplicationFormConfig() {
return applicationFormConfig;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.togetherjava.tjbot.config.FeatureBlacklist;
import org.togetherjava.tjbot.config.FeatureBlacklistConfig;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.features.basic.ApplicationCreateCommand;
import org.togetherjava.tjbot.features.basic.MemberCountDisplayRoutine;
import org.togetherjava.tjbot.features.basic.PingCommand;
import org.togetherjava.tjbot.features.basic.RoleSelectCommand;
Expand Down Expand Up @@ -164,6 +165,7 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
features.add(new BookmarksCommand(bookmarksSystem));
features.add(new ChatGptCommand(chatGptService, helpSystemHelper));
features.add(new JShellCommand(jshellEval));
features.add(new ApplicationCreateCommand(config));

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