Uh oh!
There was an error while loading. Please reload this page.
Forms system - #524
Conversation
A command to attach form buttons to bot's messages Form data deserialization Store forms in database Use an array of form fields instead of a form data object Move `FormsRepository` and `FormField` to different packages Reading forms from database Open modals on form button interaction Log submissions in a configured channel Allow setting a custom submission message Use an *Empty* value if user ommits a field Ignore case when parsing form field text input styles Store forms' origin messages, their channels, and expiration date Form delete command autocompletion Form delete command Forms closing and reopening commands Form details command Form modification command Check if the form is not closed or expired on submission Reword expiration command parameter description Additional checks in all form commands Don't accept raw JSON data and don't immediately attach forms Added `add-field` form command Form field remove command Form show command Put a limit of 5 components for forms Allow field inserting Forms attach and detach commands Prevent removing the last field from an attached form Javadocs Remove redundant checks from form commands Move some common methods to the form interaction manager Added `hasExpired` method to `FormData` Add `onetime` form parameter Logging form submissions to the database Add a repository method to query forms for a specific `closed` state Include total submissions count in the form details message Additional null checks in the forms repository Prevent further submissions to one-time forms A command to export all form submissions Delete form submissions on form deletion Command to delete user's submissions Fix checkstyle violations
danthe1st
left a comment
There was a problem hiding this comment.
This is my initial review which is about the model and database.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danthe1st
left a comment
There was a problem hiding this comment.
Round 2 of reviewing, FormInteractionManager, /form add-field, /form attach
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danthe1st
left a comment
There was a problem hiding this comment.
With this, most of the changed files should be reviewed.
TODO for myself: check with spotbugs
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danthe1st
left a comment
There was a problem hiding this comment.
This should be the last review of your initial version.
Overall, the structure is mostly good but there are quite a few things I found.
I think you could use JDA's capabilities more in some places and you are repeating yourself quite a bit between all of the subcommands. This can be refactored using a superclass for form subcommands that operate on a form. This would allow you using common handling for autocomplete, addition (the constructor in the superclass can accept FormRepository (if necessary), the description and the OptionDatas (or similar) of the subcommand) and extraction of the form-id (or form) argument and the loading of the FormData. If the FormData is present, you could call an abstract method, e.g. protected abstract execute(SlashCommandInteractionEvent event, FormData form)
This would also allow you using Optional#ifPresentOrElse for the FormData instead of Optional#get.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danthe1st
left a comment
There was a problem hiding this comment.
TODO for myself: test with native-image - there shouldn't be any issues but just in case...
danthe1st
left a comment
There was a problem hiding this comment.
Please still act on the other requested changes like unifying autocomplete.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danthe1st
commented
Sep 17, 2025
By the way, the last build failed because of checkstyle. |
I know. I will take care of checkstyle once I'm done writing the actual code. |
Signed-off-by: Defective <def3ctive4@gmail.com>
Defective4
commented
Sep 18, 2025
Also, please keep in mind that even though I'm pushing new commits, I'm still not done addressing most of the issues. I have a habit of pushing immediately after committing new changes to the code. |
danthe1st
commented
Sep 18, 2025
Just comment when you think I should re-review it. |
danthe1st
left a comment
There was a problem hiding this comment.
Most of these comments are fairly minor details.
Overall, it looks pretty good.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Okay, I've committed changes addressing all of the new review comments, except for this one |
If I didn't omit anything, I've addressed all of the old issues. I reacted with 👍 to every comment I've seen. The PR should be ready for review. |
This field relied on form's ID to be a timestamp, but that's no longer the case
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danthe1st
commented
Mar 17, 2026
Normal Testing:
I don't consider these to be necessary though. |
Defective4
commented
Mar 17, 2026
Should I fix the first issue before the PR can be merged? |
danthe1st
commented
Mar 17, 2026
You can if you want to but I don't consider this to be necessary. I will do some final tests with |
There was a problem hiding this comment.
Also seems to work with native-image.
When attempting to attach a form to a message from a user (not the bot), the following exception occurs:
java.lang.IllegalStateException: Attemptedtoupdatemessagethatwasnotsentbythisaccount. YoucannotmodifyotherUser's messages!
atnet.dv8tion.jda.internal.entities.ReceivedMessage.checkUser(ReceivedMessage.java:200)
atnet.dv8tion.jda.internal.entities.ReceivedMessage.editMessageComponents(ReceivedMessage.java:778)
atnet.dv8tion.jda.api.entities.Message.editMessageComponents(Message.java:1076)
atnet.discordjug.javabot.systems.staff_commands.forms.commands.AttachFormSubcommand.attachFormToMessage(AttachFormSubcommand.java:151)
atnet.discordjug.javabot.systems.staff_commands.forms.commands.AttachFormSubcommand.lambda$execute$1(AttachFormSubcommand.java:118)
atnet.dv8tion.jda.api.requests.Request.lambda$onSuccess$0(Request.java:131)
atjava.base@25.0.2/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1750)
atjava.base@25.0.2/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1742)
atjava.base@25.0.2/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1659)
atjava.base@25.0.2/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
atjava.base@25.0.2/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1450)
atjava.base@25.0.2/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2019)
atjava.base@25.0.2/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
atorg.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:832)
atorg.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:808)I guess a proper error message would be better.
Other than that, I think this PR is ready to be merged.
Defective4
commented
Mar 17, 2026
This issue should be fixed now |
Uh oh!
There was an error while loading. Please reload this page.
This pull request adds the forms system to the bot.
The forms can be attached to any of the bot's messages. Users can fill in a form by clicking on the button added to the message the form is attached. After doing so, the user is presented with a modal dialog containing up to 5 fields defined in the form.
Upon submission, the contents of the fields are sent to a dedicated channel (configurable per form).
Included in this PR are commands to create, manage, and customize forms.
Forms can also be configured to accept only one submission per user. This was achieved by keeping track of who had submitted the form before in the dedicated forms repository.
Below is a video showcasing how the system works, along with most of the commands:
link(the link is broken by now)I'm aware this can be improved in some areas. I'm looking forward to your reviews!