Class SubcommandData

    • Constructor Detail

      • SubcommandData

        public SubcommandData​(@Nonnull
                              java.lang.String name,
                              @Nonnull
                              java.lang.String description)
        Create an subcommand builder.
        Parameters:
        name - The subcommand name, 1-32 lowercase alphanumeric characters
        description - The subcommand description, 1-100 characters
        Throws:
        java.lang.IllegalArgumentException - If any of the following requirements are not met
        • The name must be lowercase alphanumeric (with dash), 1-32 characters long
        • The description must be 1-100 characters long
    • Method Detail

      • addOptions

        @Nonnull
        public SubcommandData addOptions​(@Nonnull
                                         OptionData... options)
        Adds up to 25 options to this subcommand.

        Required options must be added before non-required options!

        Parameters:
        options - The options to add
        Returns:
        The SubcommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If this option is required and you already added a non-required option.
        • If more than 25 options are provided.
        • If null is provided
      • addOptions

        @Nonnull
        public SubcommandData addOptions​(@Nonnull
                                         java.util.Collection<? extends OptionData> options)
        Adds up to 25 options to this subcommand.

        Required options must be added before non-required options!

        Parameters:
        options - The options to add
        Returns:
        The SubcommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If this option is required and you already added a non-required option.
        • If more than 25 options are provided.
        • If null is provided
      • addOption

        @Nonnull
        public SubcommandData addOption​(@Nonnull
                                        OptionType type,
                                        @Nonnull
                                        java.lang.String name,
                                        @Nonnull
                                        java.lang.String description,
                                        boolean required)
        Adds an option to this subcommand.

        Required options must be added before non-required options!

        Parameters:
        type - The OptionType
        name - The lowercase option name, 1-32 characters
        description - The option description, 1-100 characters
        required - Whether this option is required (See OptionData.setRequired(boolean))
        Returns:
        The SubcommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If this option is required and you already added a non-required option.
        • If more than 25 options are provided.
        • If null is provided
      • addOption

        @Nonnull
        public SubcommandData addOption​(@Nonnull
                                        OptionType type,
                                        @Nonnull
                                        java.lang.String name,
                                        @Nonnull
                                        java.lang.String description)
        Adds an option to this subcommand.
        The option is set to be non-required! You can use addOption(OptionType, String, String, boolean) to add a required option instead.

        Required options must be added before non-required options!

        Parameters:
        type - The OptionType
        name - The lowercase option name, 1-32 characters
        description - The option description, 1-100 characters
        Returns:
        The SubcommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If this option is required and you already added a non-required option.
        • If more than 25 options are provided.
        • If null is provided
      • fromData

        @Nonnull
        public static SubcommandData fromData​(@Nonnull
                                              DataObject json)
        Parses the provided serialization back into an SubcommandData instance.
        This is the reverse function for toData().
        Parameters:
        json - The serialized DataObject representing the subcommand
        Returns:
        The parsed SubcommandData instance, which can be further configured through setters
        Throws:
        ParsingException - If the serialized object is missing required fields
        java.lang.IllegalArgumentException - If any of the values are failing the respective checks such as length