Class SelectOption

    • Field Detail

      • LABEL_MAX_LENGTH

        public static final int LABEL_MAX_LENGTH
        The maximum length a select option label can have
        See Also:
        Constant Field Values
      • VALUE_MAX_LENGTH

        public static final int VALUE_MAX_LENGTH
        The maximum length a select option value can have
        See Also:
        Constant Field Values
      • DESCRIPTION_MAX_LENGTH

        public static final int DESCRIPTION_MAX_LENGTH
        The maximum length a select option description can have
        See Also:
        Constant Field Values
    • Method Detail

      • of

        @Nonnull
        @CheckReturnValue
        public static SelectOption of​(@Nonnull
                                      java.lang.String label,
                                      @Nonnull
                                      java.lang.String value)
        Creates a new SelectOption instance.
        You can further configure this with the various setters that return new instances.
        Parameters:
        label - The label for the option, up to 100 characters, as defined by LABEL_MAX_LENGTH
        value - The value for the option used to indicate which option was selected with SelectionMenuInteraction.getValues(), up to 100 characters, as defined by VALUE_MAX_LENGTH
        Returns:
        The new select option instance
        Throws:
        java.lang.IllegalArgumentException - If the null is provided, or any of the individual parameter requirements are violated.
      • withLabel

        @Nonnull
        @CheckReturnValue
        public SelectOption withLabel​(@Nonnull
                                      java.lang.String label)
        Returns a copy of this select option with the changed label.
        Parameters:
        label - The label for the option, up to 100 characters, as defined by LABEL_MAX_LENGTH
        Returns:
        The new select option instance
        Throws:
        java.lang.IllegalArgumentException - If the label is null, empty, or longer than 100 characters
      • withValue

        @Nonnull
        @CheckReturnValue
        public SelectOption withValue​(@Nonnull
                                      java.lang.String value)
        Returns a copy of this select option with the changed value.
        Parameters:
        value - The value for the option used to indicate which option was selected with SelectionMenuInteraction.getValues(), up to 100 characters, as defined by VALUE_MAX_LENGTH
        Returns:
        The new select option instance
        Throws:
        java.lang.IllegalArgumentException - If the label is null, empty, or longer than 100 characters
      • withDescription

        @Nonnull
        @CheckReturnValue
        public SelectOption withDescription​(@Nullable
                                            java.lang.String description)
        Returns a copy of this select option with the changed description of this option.
        Default: null
        Parameters:
        description - The new description or null to have no description, up to 100 characters, as defined by DESCRIPTION_MAX_LENGTH
        Returns:
        The new select option instance
        Throws:
        java.lang.IllegalArgumentException - If the provided description is longer than 100 characters
      • withDefault

        @Nonnull
        @CheckReturnValue
        public SelectOption withDefault​(boolean isDefault)
        Returns a copy of this select option with the changed default.
        Default: false
        Parameters:
        isDefault - Whether this option is selected by default
        Returns:
        The new select option instance
      • withEmoji

        @Nonnull
        @CheckReturnValue
        public SelectOption withEmoji​(@Nullable
                                      Emoji emoji)
        Returns a copy of this select option with the changed emoji.
        Default: null
        Parameters:
        emoji - The Emoji shown next to this option, or null
        Returns:
        The new select option instance
      • getLabel

        @Nonnull
        public java.lang.String getLabel()
        The current option label which would be shown to the user in the client.
        Returns:
        The label
      • getValue

        @Nonnull
        public java.lang.String getValue()
        The current option value which is used to identify the selected options in SelectionMenuInteraction.getValues().
        Returns:
        The option value
      • getDescription

        @Nullable
        public java.lang.String getDescription()
        The current description for this option.
        Returns:
        The description
      • isDefault

        public boolean isDefault()
        Whether this option is selected by default
        Returns:
        True, if this option is selected by default
      • getEmoji

        @Nullable
        public Emoji getEmoji()
        The emoji attached to this option which is shown next to the option in the selection menu
        Returns:
        The attached emoji
      • fromData

        @Nonnull
        @CheckReturnValue
        public static SelectOption fromData​(@Nonnull
                                            DataObject data)
        Inverse function for toData() which parses the serialized option data
        Parameters:
        data - The serialized option data
        Returns:
        The parsed SelectOption instance
        Throws:
        ParsingException - If the data representation is invalid
        java.lang.IllegalArgumentException - If some part of the data has an invalid length or null is provided