Annotation Interface CommandOption


@ReleasedSince("26.8.301") @Target({FIELD,TYPE}) @Retention(RUNTIME) public @interface CommandOption
Binds an interaction argument/option to a class field.

During interaction execution, the framework extracts the matching Discord option by name() and injects its mapped value directly into the annotated field via reflection before invoking the Execute method.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The unique identifier/name for this option displayed in the Discord client.
    The expected Discord data type for this option.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    A helpful description of the argument shown to users.
    boolean
    Specifies whether the user is required to supply this option when executing the command.
  • Element Details

    • type

      The expected Discord data type for this option.
      Returns:
      the option type
    • name

      String name
      The unique identifier/name for this option displayed in the Discord client.
      Returns:
      the option name
    • description

      String description
      A helpful description of the argument shown to users. Defaults to empty string (which falls back to the option name).
      Returns:
      the option description
      Default:
      ""
    • required

      boolean required
      Specifies whether the user is required to supply this option when executing the command.
      Returns:
      true if mandatory, false if optional (defaults to false)
      Default:
      false