简体   繁体   中英

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.

Use the factory method SelectOption.of :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM