Skip to content

Commit

Permalink
fix(application-form): handle no options provided
Browse files Browse the repository at this point in the history
Users with the right permissions could create a menu with no roles, and
that would cause an error.

Refs: #1024
  • Loading branch information
christolis committed Oct 6, 2024
1 parent 0bad5db commit 304fc66
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
return;
}

long incorrectArgsCount = getIncorrectRoleArgsCount(event.getInteraction().getOptions());
final List<OptionMapping> optionMappings = event.getInteraction().getOptions();
if (optionMappings.isEmpty()) {
event.reply("You have to select at least one role.").setEphemeral(true).queue();
return;
}

long incorrectArgsCount = getIncorrectRoleArgsCount(optionMappings);
if (incorrectArgsCount > 0) {
event.reply("Missing information for %d roles.".formatted(incorrectArgsCount))
.setEphemeral(true)
Expand Down

0 comments on commit 304fc66

Please sign in to comment.