Interface Parameter<T extends @NonNull Object>

Type Parameters:
T - The type of argument that is provided.

@Immutable public interface Parameter<T extends @NonNull Object>
Specification for a parameter received for a command.

Irrespective of whether the command it is used with is compatible with interactions or not, all values must be compatible with the Discord API specification for command parameters.

Since:
1.0
Version:
1.0
  • Field Details

  • Method Details

    • name

      @Pure @MatchesRegex("(?U)^[-_\\p{L}\\p{N}\\p{sc=Deva}\\p{sc=Thai}]{1,32}+$") String name()
      The name of the parameter.
      Returns:
      The value.
    • description

      @Pure @MatchesRegex("(?Us)^.{1,100}+$") String description()
      The description of the parameter.
      Returns:
      The value.
    • required

      @Pure @Default default boolean required()
      Whether the parameter must be provided to invoke the command.
      Returns:
      The value.
      Implementation Requirements:
      The default is false.
    • defaultValue

      @Pure @Nullable T defaultValue()
      The default value for the parameter.

      If null, the parameter has no default and will be null if missing.

      Note that this property is only meaningful if required() is false.

      Returns:
      The value.
      Implementation Requirements:
      The default is null.
    • parser

      @Pure ArgumentParser<?,T> parser()
      The parser to use to process received arguments.
      Returns:
      The value.
    • validate

      @Pure @Check default void validate() throws IllegalArgumentException, NullPointerException
      Validates that the properties of this instance are valid.
      Throws:
      IllegalArgumentException - if any of properties are invalid.
      NullPointerException - if a null value was found where not allowed.
      See Also:
    • builder

      @SideEffectFree static <T extends @NonNull Object> Parameter.Builder<T> builder()
      Creates a new builder.
      Type Parameters:
      T - The argument type.
      Returns:
      The builder.
    • builder

      @SideEffectFree static <T extends @NonNull Object> Parameter.Builder<T> builder(Parameter<T> base)
      Creates a new builder initialized with the properties of the given parameter.
      Type Parameters:
      T - The argument type.
      Parameters:
      base - The base instance to copy.
      Returns:
      The builder.