Skip to content

Commit b7c6552

Browse files
committed
Address the remaining issues
1 parent 4dc6fe3 commit b7c6552

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

src/main/java/net/discordjug/javabot/systems/staff_commands/forms/commands/AddFieldFormSubcommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import net.dv8tion.jda.api.interactions.commands.OptionType;
1919
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
2020
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
21+
import net.dv8tion.jda.api.modals.Modal;
2122
import xyz.dynxsty.dih4jda.interactions.AutoCompletable;
2223

2324
/**
@@ -74,7 +75,7 @@ public void execute(SlashCommandInteractionEvent event) {
7475
}
7576
FormData form = formOpt.get();
7677

77-
if (form.fields().size() >= Message.MAX_COMPONENT_COUNT) {
78+
if (form.fields().size() >= Modal.MAX_COMPONENTS) {
7879
Responses.error(event, "Can't add more than %s components to a form", Message.MAX_COMPONENT_COUNT).queue();
7980
return;
8081
}

src/main/java/net/discordjug/javabot/systems/staff_commands/forms/commands/ReopenFormSubcommand.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.discordjug.javabot.systems.staff_commands.forms.commands;
22

33
import java.util.Optional;
4-
54
import net.discordjug.javabot.data.config.BotConfig;
65
import net.discordjug.javabot.systems.staff_commands.forms.FormInteractionManager;
76
import net.discordjug.javabot.systems.staff_commands.forms.dao.FormsRepository;
@@ -60,6 +59,11 @@ public void execute(SlashCommandInteractionEvent event) {
6059
return;
6160
}
6261

62+
if (form.hasExpired()) {
63+
Responses.error(event, "You can't reopen an expired form").queue();
64+
return;
65+
}
66+
6367
event.deferReply(true).queue();
6468

6569
interactionManager.reopenForm(event.getGuild(), form);

src/main/java/net/discordjug/javabot/systems/staff_commands/forms/dao/FormsRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public Map<FormUser, Integer> getSubmissionsCountPerUser(FormData form) {
152152
* Get a form for given ID.
153153
*
154154
* @param formId form ID to query
155-
* @return optional form
155+
* @return the obtained form or {@link Optional#empty()}
156156
*/
157157
public Optional<FormData> getForm(long formId) {
158158
try {

src/main/resources/database/migrations/09-08-2025_forms.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ CREATE TABLE form_fields (
2626
);
2727

2828
CREATE TABLE form_submissions (
29-
id BIGINT NOT NULL AUTO_INCREMENT,
3029
message_id BIGINT NOT NULL,
3130
user_id BIGINT NOT NULL,
3231
form_id BIGINT NOT NULL,
3332
user_name VARCHAR NOT NULL,
34-
PRIMARY KEY (id),
33+
PRIMARY KEY (message_id),
3534
FOREIGN KEY (form_id) REFERENCES FORMS(form_id) ON DELETE CASCADE ON UPDATE RESTRICT
3635
);
3736

0 commit comments

Comments
 (0)