Skip to content

Commit 3b24656

Browse files
committed
Fix option to modify form expiration date
1 parent 4cb7103 commit 3b24656

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ModifyFormSubcommand(FormsRepository formsRepo, BotConfig botConfig) {
4343
new OptionData(OptionType.STRING, "submit-message",
4444
"Message displayed to the user once they submit the form"),
4545
new OptionData(OptionType.STRING, "expiration",
46-
"UTC time after which the form stops accepting submissions. - for no expiration"
46+
"UTC time after which the form stops accepting submissions. - for no expiration. "
4747
+ FormInteractionManager.DATE_FORMAT_STRING),
4848
new OptionData(OptionType.BOOLEAN, "onetime",
4949
"If the form should only accept one submission per user. Defaults to false.")));
@@ -67,15 +67,18 @@ public void execute(SlashCommandInteractionEvent event) {
6767
if (event.getOption("expiration") == null) {
6868
expiration = oldForm.expiration();
6969
} else {
70-
if ("-".equals(event.getOption("expiration", OptionMapping::getAsString))) expiration = null;
71-
Optional<Instant> expirationOpt;
72-
try {
73-
expirationOpt = FormInteractionManager.parseExpiration(event);
74-
} catch (IllegalArgumentException e) {
75-
event.getHook().sendMessage(e.getMessage()).queue();
76-
return;
70+
if ("-".equals(event.getOption("expiration", OptionMapping::getAsString))) {
71+
expiration = null;
72+
} else {
73+
Optional<Instant> expirationOpt;
74+
try {
75+
expirationOpt = FormInteractionManager.parseExpiration(event);
76+
} catch (IllegalArgumentException e) {
77+
event.getHook().sendMessage(e.getMessage()).queue();
78+
return;
79+
}
80+
expiration = expirationOpt.orElse(oldForm.expiration());
7781
}
78-
expiration = expirationOpt.orElse(oldForm.expiration());
7982
}
8083

8184
boolean onetime = event.getOption("onetime", oldForm.onetime(), OptionMapping::getAsBoolean);

0 commit comments

Comments
 (0)