Class SelectionDialog.Builder

Enclosing class:
SelectionDialog

public static class SelectionDialog.Builder extends Menu.Builder<SelectionDialog.Builder,SelectionDialog>
Author:
John Grosh
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public SelectionDialog build()
      Builds the SelectionDialog with this Builder.
      Specified by:
      build in class Menu.Builder<SelectionDialog.Builder,SelectionDialog>
      Returns:
      The OrderedMenu built from this Builder.
      Throws:
      IllegalArgumentException - If one of the following is violated:
    • setColor

      public SelectionDialog.Builder setColor(Color color)
      Sets the Color of the MessageEmbed.
      Parameters:
      color - The Color of the MessageEmbed
      Returns:
      This builder
    • setColor

      public SelectionDialog.Builder setColor(Function<Integer,Color> color)
      Sets the Color of the MessageEmbed, relative to the current selection number as determined by the provided Function.
      As the selection changes, the Function will re-process the current selection number, allowing for the color of the embed to change depending on the selection number.
      Parameters:
      color - A Function that uses current selection number to get a Color for the MessageEmbed
      Returns:
      This builder
    • setText

      public SelectionDialog.Builder setText(String text)
      Sets the text of the Message to be displayed when the SelectionDialog is built.

      This is displayed directly above the embed.

      Parameters:
      text - The Message content to be displayed above the embed when the SelectionDialog is built
      Returns:
      This builder
    • setText

      Sets the text of the Message to be displayed relative to the current selection number as determined by the provided Function.
      As the selection changes, the Function will re-process the current selection number, allowing for the displayed text of the Message to change depending on the selection number.
      Parameters:
      text - A Function that uses current selection number to get a text for the Message
      Returns:
      This builder
    • setSelectedEnds

      public SelectionDialog.Builder setSelectedEnds(String left, String right)
      Sets the text to use on either end of the selected item.
      Usage is primarily to mark which item is currently selected.
      Parameters:
      left - The left selection end
      right - The right selection end
      Returns:
      This builder
    • setDefaultEnds

      public SelectionDialog.Builder setDefaultEnds(String left, String right)
      Sets the text to use on either side of all unselected items. This will not be applied to the selected item.
      Usage is primarily to mark which items are not currently selected.
      Parameters:
      left - The left non-selection end
      right - The right non-selection end
      Returns:
      This builder
    • useLooping

      public SelectionDialog.Builder useLooping(boolean loop)
      Sets if moving up when at the top selection jumps to the bottom, and visa-versa.
      Parameters:
      loop - true if pressing up while at the top selection should loop to the bottom, false if it should not
      Returns:
      This builder
    • useSingleSelectionMode

      public SelectionDialog.Builder useSingleSelectionMode(boolean singleSelectionMode)
      Sets if the Menu should exit when a selection was made. By default, this is false and the menu continues showing choices even after a selection was made.
      Parameters:
      singleSelectionMode - true if the menu should exit after the first selection being made
      Returns:
      This builder
    • setSelectionConsumer

      public SelectionDialog.Builder setSelectionConsumer(BiConsumer<net.dv8tion.jda.api.entities.Message,Integer> selection)
      Sets a BiConsumer action to perform once a selection is made.
      The Message provided is the one used to display the menu and the Integer is that of the selection made by the user, and selections are in order of addition, 1 being the first String choice.
      Parameters:
      selection - A Consumer for the selection. This is one-based indexing.
      Returns:
      This builder
    • setCanceled

      public SelectionDialog.Builder setCanceled(Consumer<net.dv8tion.jda.api.entities.Message> cancel)
      Sets a Consumer action to take if the menu is cancelled, either via the cancel button being used, or if the SelectionDialog times out.
      Parameters:
      cancel - The action to take when the SelectionDialog is cancelled
      Returns:
      This builder
    • clearChoices

      public SelectionDialog.Builder clearChoices()
      Clears the choices to be shown.
      Returns:
      This builder
    • setChoices

      public SelectionDialog.Builder setChoices(String... choices)
      Sets the String choices to be shown as selections.
      Parameters:
      choices - The String choices to show
      Returns:
      the builder
    • addChoices

      public SelectionDialog.Builder addChoices(String... choices)
      Adds String choices to be shown as selections.
      Parameters:
      choices - The String choices to add
      Returns:
      This builder