Skip to content

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

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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

christolis
Copy link
Member

@christolis christolis commented Mar 8, 2024

Closes #1024.

Screenshots

ScreenRecording2024-03-11at18 29 35-ezgif com-video-to-gif-converter
image

Configuration changes

Property Description Type Default
applicationForm.applicationChannelPattern Where submitted
applications end up.
String "applications-log"

TODO

  • Add a 5 minute cooldown per member for sending applications to prevent spam (feel free to recommend alternatives).
    • This could be done by having a HashMap<Member, OffsetDateTime> where the key is the Member who sent an application and the value is the date and time that they sent it. There should be a condition every time a Member attempts to send any application which utilizes the aforementioned HashMap to prevent spam.
  • Add JavaDocs for every method where it's necessary.
  • Switch to EntitySelectInteractionEvent for the dropdown menu. (EDIT: Impossible since this would forcibly include all existing roles)
  • Move selectable roles from the config to the command parameters in a similar fashion with previous commands.
    • This eliminates emoji/description metadata as well that was previously defined in the configuration file.

@christolis christolis added enhancement New feature or request new command Add a new command or group of commands to the bot priority: major labels Mar 8, 2024
@christolis christolis self-assigned this Mar 8, 2024
@Suleman70
Copy link
Member

Can i be assigned to this?

@christolis christolis marked this pull request as ready for review March 9, 2024 10:17
@christolis christolis requested a review from a team as a code owner March 9, 2024 10:17
@Suleman70 Suleman70 removed their assignment Mar 16, 2024
Copy link
Member

@Taz03 Taz03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

branch update is required, it is using removed APIs

@christolis christolis force-pushed the feature/application-form branch from 5c0ef6e to 3159bed Compare March 19, 2024 21:28
@christolis christolis marked this pull request as draft March 19, 2024 22:16
@christolis
Copy link
Member Author

Marked PR as draft since there needs to be some rework on certain things which will be specified in the TODO.

@christolis christolis force-pushed the feature/application-form branch 2 times, most recently from cb7815a to 042a0e0 Compare April 4, 2024 09:48
@christolis christolis marked this pull request as ready for review April 4, 2024 22:12
@christolis christolis requested a review from Taz03 April 4, 2024 22:18
@ankitsmt211 ankitsmt211 added the config-changes if your PR contains any changes related to config file label May 18, 2024
@ankitsmt211
Copy link
Member

@christolis what happens to the generated form after x user applies through form? Does the form need to be re-created? Or is it only unavailable for x user to a certain time period?

Also how do we update the form if need be?
Delete message and recreate?

@christolis christolis force-pushed the feature/application-form branch from 1a8e458 to 29c8ee6 Compare October 6, 2024 11:39
@christolis
Copy link
Member Author

@christolis what happens to the generated form after x user applies through form? Does the form need to be re-created? Or is it only unavailable for x user to a certain time period?

Also how do we update the form if need be? Delete message and recreate?

The generated form is persistent and used by everybody. It does not need to be recreated by whoever has the MANAGE_ROLES permission. As for updating it, that's right. Currently, the way it is developed, the message has to be deleted and get the command executed again, which is not that big of a problem considering the rarity of updating such form.

Copy link
Contributor

@surajkumar surajkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR and the thought put into the development of the feature is evident.

Please can you look into the comments, additionally, there are some duplicate checks happening e.g. multiple guild == null checks. This can be done once much earlier and then you don't have to worry about it.

@christolis christolis force-pushed the feature/application-form branch 4 times, most recently from 0b18118 to a8178b9 Compare October 17, 2024 20:02
tj-wazei
tj-wazei previously approved these changes Oct 17, 2024
Copy link

@tj-wazei tj-wazei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

tj-wazei
tj-wazei previously approved these changes Oct 17, 2024
Copy link
Member

@SquidXTV SquidXTV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your effort <3

Comment on lines +121 to +183
"minimumAnswerLength": 50,
"maximumAnswerLength": 500,
"applicationSubmitCooldownMinutes": 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these 3 can be hardcoded. not needed in the config

* This command is designed to generate an application form for members to apply for roles within a
* guild.
*/
public class ApplicationCreateCommand extends SlashCommandAdapter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the feature should be renamed to match the package name. CreateRoleApplicationCommand

* that submissions are sent to the appropriate application channel, and enforcing cooldowns for
* users to prevent spamming.
*/
public class ApplicationApplyHandler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the feature should be renamed to match the package name. RoleApplicationHandler

private static final int ARG_COUNT = 3;

private final ApplicationApplyHandler applicationApplyHandler;
private final RoleApplicationSystemConfig roleApplicationSystemConfig;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u can just call it config for simplicity

private static final String VALUE_DELIMITER = "_";
private static final int ARG_COUNT = 3;

private final ApplicationApplyHandler applicationApplyHandler;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u could call it just handler for simplicity. context is clear within this class

.setTimestamp(Instant.now())
.setFooter("Submitted at");

String roleString = args.getLast();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer extracting the args at the beginning, right after ur length check. and id prefer explicit indices here to make sure the thing is at the index u expected. so args.get(1) in this case

Comment on lines +68 to +70
if (args.size() != 2 || guild == null) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like this would be an error case that should emit a log message instead of silent failure?

Comment on lines +73 to +75
if (applicationChannel.isEmpty()) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning instead of silent failure?

Comment on lines +81 to +82
.setTimestamp(Instant.now())
.setFooter("Submitted at");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer reordering these two calls so it tells the story better "Submitted at ... Instant.now()"

return applicationSubmitCooldown;
}

protected void submitApplicationFromModalInteraction(ModalInteractionEvent event,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why protected? this class doesnt make use of inheritance. id remove all the protected and make the class final instead

@LovinLifee
Copy link

Commenting so I can be assigned

@christolis christolis force-pushed the feature/application-form branch from a226d33 to f46c983 Compare June 27, 2025 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config-changes if your PR contains any changes related to config file enhancement New feature or request new command Add a new command or group of commands to the bot priority: major
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Add slash command to generate application form for various community roles
9 participants