Skip to content

Commit 8651807

Browse files
committed
feat: move substring of label into config record
1 parent 375ae45 commit 8651807

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

application/config.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
},
178178
"roleApplicationSystem": {
179179
"submissionsChannelPattern": "staff-applications",
180-
"defaultQuestion": "What makes you a valuable addition to the team? 😎",
180+
"defaultQuestion": "What makes you a good addition to the team?",
181181
"minimumAnswerLength": 50,
182182
"maximumAnswerLength": 500,
183183
"applicationSubmitCooldownMinutes": 5

application/src/main/java/org/togetherjava/tjbot/config/RoleApplicationSystemConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.togetherjava.tjbot.config;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import net.dv8tion.jda.api.interactions.components.text.TextInput;
45

56
import java.util.Objects;
67

@@ -26,5 +27,9 @@ public record RoleApplicationSystemConfig(
2627
public RoleApplicationSystemConfig {
2728
Objects.requireNonNull(submissionsChannelPattern);
2829
Objects.requireNonNull(defaultQuestion);
30+
31+
if (defaultQuestion.length() > TextInput.MAX_LABEL_LENGTH) {
32+
throw new IllegalArgumentException("defaultQuestion length is too long! Cannot be greater than %d".formatted(TextInput.MAX_LABEL_LENGTH));
33+
}
2934
}
3035
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,8 @@ public void onStringSelectSelection(StringSelectInteractionEvent event, List<Str
134134
return;
135135
}
136136

137-
String questionLabel = roleApplicationSystemConfig.defaultQuestion();
138-
if (questionLabel.length() > TextInput.MAX_LABEL_LENGTH) {
139-
questionLabel = questionLabel.substring(0, TextInput.MAX_LABEL_LENGTH);
140-
}
141-
142137
TextInput body = TextInput
143-
.create(generateComponentId(event.getUser().getId()), questionLabel,
138+
.create(generateComponentId(event.getUser().getId()), roleApplicationSystemConfig.defaultQuestion(),
144139
TextInputStyle.PARAGRAPH)
145140
.setRequired(true)
146141
.setRequiredRange(roleApplicationSystemConfig.minimumAnswerLength(),

0 commit comments

Comments
 (0)