Class SelectMenuBuilder

java.lang.Object
me.axolotl.api.discord.util.builder.SelectMenuBuilder

public abstract class SelectMenuBuilder extends Object
SelectMenuBuilder類提供了一個用於構建帶有選項的選擇選單的模板。
Since:
2024-02-22
  • Constructor Summary

    Constructors
    Constructor
    Description
    使用指定的ID構造一個新的SelectMenuBuilder。
    SelectMenuBuilder(String id, T options)
    使用指定的ID和選項構造一個新的SelectMenuBuilder。
    SelectMenuBuilder(String id, T options, boolean disable)
    使用指定的ID、選項和禁用狀態構造一個新的SelectMenuBuilder。
    SelectMenuBuilder(String id, T options, boolean disable, int minValue, int maxValue)
    使用指定的ID、選項、禁用狀態、最小值和最大值構造一個新的SelectMenuBuilder。
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    禁用選擇選單。
    void
    啟用選擇選單。
    獲取選擇選單的ID。
    net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu
    獲取表示選擇選單的SelectMenu對象。
    @Nullable net.dv8tion.jda.api.interactions.components.selections.SelectOption
    根據ID獲取選項。
    List<net.dv8tion.jda.api.interactions.components.selections.SelectOption>
    獲取選擇選單的選項。
    abstract void
    onSelected(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
    指定當從選擇選單中選擇一個選項時要執行的操作。
    void
    setMaxValue(int maxValue)
    設置允許選擇的最大值。
    void
    setMinValue(int minValue)
    設置允許選擇的最小值。

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SelectMenuBuilder

      public SelectMenuBuilder(String id)
      使用指定的ID構造一個新的SelectMenuBuilder。
      Parameters:
      id - 選擇選單的ID
    • SelectMenuBuilder

      public SelectMenuBuilder(String id, T options)
      使用指定的ID和選項構造一個新的SelectMenuBuilder。
      Parameters:
      id - 選擇選單的ID
      options - 選擇選單的選項
    • SelectMenuBuilder

      public SelectMenuBuilder(String id, T options, boolean disable)
      使用指定的ID、選項和禁用狀態構造一個新的SelectMenuBuilder。
      Parameters:
      id - 選擇選單的ID
      options - 選擇選單的選項
      disable - 選擇選單的禁用狀態
    • SelectMenuBuilder

      public SelectMenuBuilder(String id, T options, boolean disable, int minValue, int maxValue)
      使用指定的ID、選項、禁用狀態、最小值和最大值構造一個新的SelectMenuBuilder。
      Parameters:
      id - 選擇選單的ID
      options - 選擇選單的選項
      disable - 選擇選單的禁用狀態
      minValue - 選擇選單的允許的最小值
      maxValue - 選擇選單的允許的最大值
  • Method Details

    • getId

      public String getId()
      獲取選擇選單的ID。
      Returns:
      選擇選單的ID
    • asEnable

      public void asEnable()
      啟用選擇選單。
    • asDisable

      public void asDisable()
      禁用選擇選單。
    • setMinValue

      public void setMinValue(int minValue)
      設置允許選擇的最小值。
      Parameters:
      minValue - 允許選擇的最小值
    • setMaxValue

      public void setMaxValue(int maxValue)
      設置允許選擇的最大值。
      Parameters:
      maxValue - 允許選擇的最大值
    • getOptions

      public List<net.dv8tion.jda.api.interactions.components.selections.SelectOption> getOptions()
      獲取選擇選單的選項。
      Returns:
      選擇選單的選項列表
    • getOptionById

      @Nullable public @Nullable net.dv8tion.jda.api.interactions.components.selections.SelectOption getOptionById(String id)
      根據ID獲取選項。
      Parameters:
      id - 選項的ID
      Returns:
      具有指定ID的選項的文本
    • getMenu

      public net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu getMenu()
      獲取表示選擇選單的SelectMenu對象。
      Returns:
      表示選擇選單的SelectMenu對象
    • onSelected

      public abstract void onSelected(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
      指定當從選擇選單中選擇一個選項時要執行的操作。
      Parameters:
      event - 表示選擇選項的事件