-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
base: develop
Are you sure you want to change the base?
Feat: Add slash command to generate application form for various community roles #1049
Conversation
Can i be assigned to this? |
There was a problem hiding this 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
5c0ef6e
to
3159bed
Compare
Marked PR as draft since there needs to be some rework on certain things which will be specified in the TODO. |
cb7815a
to
042a0e0
Compare
@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? |
1a8e458
to
29c8ee6
Compare
The generated form is persistent and used by everybody. It does not need to be recreated by whoever has the |
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
0b18118
to
a8178b9
Compare
.../src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/config/RoleApplicationSystemConfig.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
.../src/main/java/org/togetherjava/tjbot/features/roleapplication/ApplicationCreateCommand.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
"minimumAnswerLength": 50, | ||
"maximumAnswerLength": 500, | ||
"applicationSubmitCooldownMinutes": 5 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
if (args.size() != 2 || guild == null) { | ||
return; | ||
} |
There was a problem hiding this comment.
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?
if (applicationChannel.isEmpty()) { | ||
return; | ||
} |
There was a problem hiding this comment.
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?
.setTimestamp(Instant.now()) | ||
.setFooter("Submitted at"); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
Commenting so I can be assigned |
Co-authored-by: Suraj Kumar <76599223+surajkumar@users.noreply.github.com>
This removes the permission check for the bot to have the `MANAGE_ROLES` permission in order to execute the command.
a226d33
to
f46c983
Compare
Closes #1024.
Screenshots
Configuration changes
applicationForm.applicationChannelPattern
applications end up.
"applications-log"
TODO
HashMap<Member, OffsetDateTime>
where the key is theMember
who sent an application and the value is the date and time that they sent it. There should be a condition every time aMember
attempts to send any application which utilizes the aforementionedHashMap
to prevent spam.Switch to(EDIT: Impossible since this would forcibly include all existing roles)EntitySelectInteractionEvent
for the dropdown menu.