Skip to content

Commit 083058d

Browse files
committed
style: add JavaDocs where necessary
1 parent e83db20 commit 083058d

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
import java.util.List;
66
import java.util.Objects;
77

8+
/**
9+
* Represents the configuration for an application form, including roles and application channel
10+
* pattern.
11+
*/
812
public record ApplicationFormConfig(
913
@JsonProperty(value = "roles", required = true) List<ApplyRoleConfig> applyRoleConfig,
1014
@JsonProperty(value = "applicationChannelPattern",
1115
required = true) String applicationChannelPattern) {
1216

17+
/**
18+
* Constructs an instance of {@link ApplicationFormConfig} with the provided parameters.
19+
*
20+
* @param applyRoleConfig the list of ApplyRoleConfig objects defining roles for the application
21+
* form
22+
* @param applicationChannelPattern the pattern used to identify the application channel
23+
*/
1324
public ApplicationFormConfig {
1425
Objects.requireNonNull(applyRoleConfig);
1526
Objects.requireNonNull(applicationChannelPattern);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@
44

55
import java.util.Objects;
66

7+
/**
8+
* Represents the configuration for applying a role.
9+
*/
710
public record ApplyRoleConfig(@JsonProperty(value = "name", required = true) String name,
811
@JsonProperty(value = "description", required = true) String description,
912
@JsonProperty(value = "formattedEmoji") String emoji) {
1013

14+
/**
15+
* Constructs an instance of ApplyRoleConfig with the given parameters.
16+
*
17+
* @param name the name of the role
18+
* @param description the description of the role
19+
* @param emoji the emoji associated with the role
20+
*/
1121
public ApplyRoleConfig {
1222
Objects.requireNonNull(name);
1323
Objects.requireNonNull(description);

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
import java.util.function.Predicate;
4040
import java.util.regex.Pattern;
4141

42+
/**
43+
* Represents a command to create an application form for members to apply for roles.
44+
* <p>
45+
* This command is designed to generate an application form for members to apply for roles within a
46+
* guild.
47+
*/
4248
public class ApplicationCreateCommand extends SlashCommandAdapter {
4349
private static final Logger logger = LoggerFactory.getLogger(ApplicationCreateCommand.class);
4450

@@ -50,6 +56,13 @@ public class ApplicationCreateCommand extends SlashCommandAdapter {
5056
private final Predicate<String> applicationChannelPattern;
5157
private final ApplicationFormConfig config;
5258

59+
/**
60+
* Constructs a new {@code ApplicationCreateCommand} with the specified configuration.
61+
* <p>
62+
* This command is designed to generate an application form for members to apply for roles.
63+
*
64+
* @param config the configuration containing the settings for the application form
65+
*/
5366
public ApplicationCreateCommand(Config config) {
5467
super("application-form", "Generates an application form for members to apply for roles.",
5568
CommandVisibility.GUILD);
@@ -83,6 +96,17 @@ public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
8396
event.reply("").addActionRow(menu.build()).setEphemeral(true).queue();
8497
}
8598

99+
/**
100+
* Maps a user and an {@link ApplyRoleConfig} option to a SelectOption object.
101+
* <p>
102+
* This method is used to create a SelectOption object that represents a role configuration
103+
* option for a user, including a unique component ID generated based on the user's ID and the
104+
* option's name, a description, and an emoji.
105+
*
106+
* @param user the user for whom the role configuration option is being mapped
107+
* @param option the {@link ApplyRoleConfig} option to be mapped to a SelectOption
108+
* @return a {@link SelectOption} object with the specified details
109+
*/
86110
private SelectOption mapToSelectOption(User user, ApplyRoleConfig option) {
87111
return SelectOption.of(option.name(), generateComponentId(user.getId(), option.name()))
88112
.withDescription(option.description())
@@ -140,6 +164,13 @@ public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
140164
.queue();
141165
}
142166

167+
/**
168+
* Retrieves the application channel from the given {@link Guild}.
169+
*
170+
* @param guild the guild from which to retrieve the application channel
171+
* @return an {@link Optional} containing the {@code TextChannel} representing the application
172+
* channel, or an empty {@link Optional} if no such channel is found
173+
*/
143174
private Optional<TextChannel> getApplicationChannel(Guild guild) {
144175
return guild.getChannels()
145176
.stream()
@@ -176,6 +207,17 @@ private boolean handleHasPermissions(SlashCommandInteractionEvent event) {
176207
return true;
177208
}
178209

210+
/**
211+
* Sends the result of an application submission to the designated application channel in the
212+
* guild.
213+
* <p>
214+
* The {@code args} parameter should contain the applicant's name and the role they are applying
215+
* for.
216+
*
217+
* @param event the modal interaction event triggering the application submission
218+
* @param args the arguments provided in the application submission
219+
* @param answer the answer provided by the applicant to the default question
220+
*/
179221
private void sendApplicationResult(final ModalInteractionEvent event, List<String> args,
180222
String answer) {
181223
Guild guild = event.getGuild();
@@ -205,6 +247,11 @@ private void sendApplicationResult(final ModalInteractionEvent event, List<Strin
205247
applicationChannel.get().sendMessageEmbeds(embed.build()).queue();
206248
}
207249

250+
/**
251+
* Sends the initial embed and a button which displays role openings.
252+
*
253+
* @param event the command interaction event triggering the menu
254+
*/
208255
private void sendMenu(final CommandInteraction event) {
209256
MessageEmbed embed = createApplicationEmbed();
210257

0 commit comments

Comments
 (0)