3939import java .util .function .Predicate ;
4040import 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+ */
4248public 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