Skip to content

Commit 304fc66

Browse files
committed
fix(application-form): handle no options provided
Users with the right permissions could create a menu with no roles, and that would cause an error. Refs: Together-Java#1024
1 parent 0bad5db commit 304fc66

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

application/src/main/java/org/togetherjava/tjbot/features/basic/ApplicationCreateCommand.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
119119
return;
120120
}
121121

122-
long incorrectArgsCount = getIncorrectRoleArgsCount(event.getInteraction().getOptions());
122+
final List<OptionMapping> optionMappings = event.getInteraction().getOptions();
123+
if (optionMappings.isEmpty()) {
124+
event.reply("You have to select at least one role.").setEphemeral(true).queue();
125+
return;
126+
}
127+
128+
long incorrectArgsCount = getIncorrectRoleArgsCount(optionMappings);
123129
if (incorrectArgsCount > 0) {
124130
event.reply("Missing information for %d roles.".formatted(incorrectArgsCount))
125131
.setEphemeral(true)

0 commit comments

Comments
 (0)