Search code examples
javadiscordprotecteddiscord-jda

JDA List/Collection of SelectOption


I cant create a List or a Collection of SelectOptions in JDA. I tried it like that:

List<SelectOption> li = new ArrayList<>();
    li.add(new SelectOption("", ""));

The error message tells me this:

'SelectOption(java.lang.String, java.lang.String)' has protected access in 'net.dv8tion.jda.api.interactions.components.selections.SelectOption'

I dont know what does this mean and how i fix that.


Solution

  • Use the factory method SelectOption.of:

    SelectOption.of("What the user sees", "id used in event")
      .withDescription("Some description to show below the label")