Class CommandData

    • Constructor Detail

      • CommandData

        public CommandData​(@Nonnull
                           java.lang.String name,
                           @Nonnull
                           java.lang.String description)
        Create an command builder.
        Parameters:
        name - The command name, 1-32 lowercase alphanumeric characters
        description - The command 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

      • setDefaultEnabled

        @Nonnull
        public CommandData setDefaultEnabled​(boolean enabled)
        Whether this command is available to everyone by default.
        If this is disabled, you need to explicitly whitelist users and roles per guild.
        Parameters:
        enabled - True, if this command is enabled by default for everyone. (Default: true)
        Returns:
        The CommandData instance, for chaining
      • addOptions

        @Nonnull
        public CommandData addOptions​(@Nonnull
                                      OptionData... options)
        Adds up to 25 options to this command.

        Required options must be added before non-required options!

        Parameters:
        options - The Options to add
        Returns:
        The CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If you try to mix subcommands/options/groups in one command.
        • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
        • 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 CommandData addOptions​(@Nonnull
                                      java.util.Collection<? extends OptionData> options)
        Adds up to 25 options to this command.

        Required options must be added before non-required options!

        Parameters:
        options - The Options to add
        Returns:
        The CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If you try to mix subcommands/options/groups in one command.
        • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
        • 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 CommandData addOption​(@Nonnull
                                     OptionType type,
                                     @Nonnull
                                     java.lang.String name,
                                     @Nonnull
                                     java.lang.String description,
                                     boolean required)
        Adds an option to this command.

        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 CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If you try to mix subcommands/options/groups in one command.
        • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
        • 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 CommandData addOption​(@Nonnull
                                     OptionType type,
                                     @Nonnull
                                     java.lang.String name,
                                     @Nonnull
                                     java.lang.String description)
        Adds an option to this command.
        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 CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException -
        • If you try to mix subcommands/options/groups in one command.
        • If the option type is OptionType.SUB_COMMAND or OptionType.SUB_COMMAND_GROUP.
        • If this option is required and you already added a non-required option.
        • If more than 25 options are provided.
        • If null is provided
      • addSubcommands

        @Nonnull
        public CommandData addSubcommands​(@Nonnull
                                          SubcommandData... subcommands)
        Add up to 25 Subcommands to this command.
        Parameters:
        subcommands - The subcommands to add
        Returns:
        The CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or more than 25 subcommands are provided. Also throws if you try to mix subcommands/options/groups in one command.
      • addSubcommands

        @Nonnull
        public CommandData addSubcommands​(@Nonnull
                                          java.util.Collection<? extends SubcommandData> subcommands)
        Add up to 25 Subcommands to this command.
        Parameters:
        subcommands - The subcommands to add
        Returns:
        The CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or more than 25 subcommands are provided. Also throws if you try to mix subcommands/options/groups in one command.
      • addSubcommandGroups

        @Nonnull
        public CommandData addSubcommandGroups​(@Nonnull
                                               SubcommandGroupData... groups)
        Add up to 25 Subcommand-Groups to this command.
        Parameters:
        groups - The subcommand groups to add
        Returns:
        The CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or more than 25 subcommand groups are provided. Also throws if you try to mix subcommands/options/groups in one command.
      • addSubcommandGroups

        @Nonnull
        public CommandData addSubcommandGroups​(@Nonnull
                                               java.util.Collection<? extends SubcommandGroupData> groups)
        Add up to 25 Subcommand-Groups to this command.
        Parameters:
        groups - The subcommand groups to add
        Returns:
        The CommandData instance, for chaining
        Throws:
        java.lang.IllegalArgumentException - If null is provided, or more than 25 subcommand groups are provided. Also throws if you try to mix subcommands/options/groups in one command.
      • fromData

        @Nonnull
        public static CommandData fromData​(@Nonnull
                                           DataObject object)
        Parses the provided serialization back into an CommandData instance.
        This is the reverse function for toData().
        Parameters:
        object - The serialized DataObject representing the command
        Returns:
        The parsed CommandData 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
      • fromList

        @Nonnull
        public static java.util.List<CommandData> fromList​(@Nonnull
                                                           DataArray array)
        Parses the provided serialization back into an CommandData instance.
        This is the reverse function for toData().
        Parameters:
        array - Array of serialized DataObject representing the commands
        Returns:
        The parsed CommandData instances, 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
      • fromList

        @Nonnull
        public static java.util.List<CommandData> fromList​(@Nonnull
                                                           java.util.Collection<? extends DataObject> collection)
        Parses the provided serialization back into an CommandData instance.
        This is the reverse function for toData().
        Parameters:
        collection - Collection of serialized DataObject representing the commands
        Returns:
        The parsed CommandData instances, 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