Class SubcommandGroupData

java.lang.Object
net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData
All Implemented Interfaces:
SerializableData

public class SubcommandGroupData extends Object implements SerializableData
Builder for a Slash-Command group.
  • Constructor Details

    • SubcommandGroupData

      public SubcommandGroupData(@Nonnull String name, @Nonnull String description)
      Create an group builder.
      Parameters:
      name - The group name, 1-32 lowercase alphanumeric characters
      description - The group description, 1-100 characters
      Throws:
      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 Details

    • setName

      @Nonnull public SubcommandGroupData setName(@Nonnull String name)
      Configure the name
      Parameters:
      name - The lowercase alphanumeric (with dash) name, 1-32 characters
      Returns:
      The SubcommandGroupData instance, for chaining
      Throws:
      IllegalArgumentException - If the name is null, not alphanumeric, or not between 1-32 characters
    • setNameLocalization

      @Nonnull public SubcommandGroupData setNameLocalization(@Nonnull DiscordLocale locale, @Nonnull String name)
      Sets a language-specific localization of this subcommand group's name.
      Parameters:
      locale - The locale to associate the translated name with
      name - The translated name to put
      Returns:
      This builder instance, for chaining
      Throws:
      IllegalArgumentException -
    • setNameLocalizations

      @Nonnull public SubcommandGroupData setNameLocalizations(@Nonnull Map<DiscordLocale, String> map)
      Sets multiple language-specific localizations of this subcommand group's name.
      Parameters:
      map - The map from which to transfer the translated names
      Returns:
      This builder instance, for chaining
      Throws:
      IllegalArgumentException -
    • setDescription

      @Nonnull public SubcommandGroupData setDescription(@Nonnull String description)
      Configure the description
      Parameters:
      description - The description, 1-100 characters
      Returns:
      The SubcommandGroupData instance, for chaining
      Throws:
      IllegalArgumentException - If the name is null or not between 1-100 characters
    • setDescriptionLocalization

      @Nonnull public SubcommandGroupData setDescriptionLocalization(@Nonnull DiscordLocale locale, @Nonnull String description)
      Sets a language-specific localization of this subcommand group's description.
      Parameters:
      locale - The locale to associate the translated description with
      description - The translated description to put
      Returns:
      This builder instance, for chaining
      Throws:
      IllegalArgumentException -
    • setDescriptionLocalizations

      @Nonnull public SubcommandGroupData setDescriptionLocalizations(@Nonnull Map<DiscordLocale, String> map)
      Sets multiple language-specific localizations of this subcommand group's description.
      Parameters:
      map - The map from which to transfer the translated descriptions
      Returns:
      This builder instance, for chaining
      Throws:
      IllegalArgumentException -
    • getName

      @Nonnull public String getName()
      The name for this subcommand group
      Returns:
      The name
    • getNameLocalizations

      @Nonnull public LocalizationMap getNameLocalizations()
      The localizations of this subcommand's name for various languages group.
      Returns:
      The LocalizationMap containing the mapping from DiscordLocale to the localized name
    • getDescription

      @Nonnull public String getDescription()
      The description for this subcommand group
      Returns:
      The description
    • getDescriptionLocalizations

      @Nonnull public LocalizationMap getDescriptionLocalizations()
      The localizations of this subcommand's description for various languages group.
      Returns:
      The LocalizationMap containing the mapping from DiscordLocale to the localized description
    • removeSubcommand

      public boolean removeSubcommand(@Nonnull Predicate<? super SubcommandData> condition)
      Removes all subcommands that evaluate to true under the provided condition.

      Example: Remove all subcommands

      command.removeSubcommands(subcommand -> true);
      
      Parameters:
      condition - The removal condition (must not throw)
      Returns:
      True, if any subcommands were removed
      Throws:
      IllegalArgumentException - If the condition is null
    • removeSubcommandByName

      public boolean removeSubcommandByName(@Nonnull String name)
      Removes subcommands by the provided name.
      Parameters:
      name - The case-sensitive subcommand name
      Returns:
      True, if any subcommands were removed
    • getSubcommands

      @Nonnull public @Unmodifiable List<SubcommandData> getSubcommands()
      The Subcommands in this group.
      Returns:
      Immutable list of SubcommandData
    • addSubcommands

      @Nonnull public SubcommandGroupData addSubcommands(@Nonnull SubcommandData... subcommands)
      Add up to 25 Subcommands to this group.
      Parameters:
      subcommands - The subcommands to add
      Returns:
      The SubcommandGroupData instance, for chaining
      Throws:
      IllegalArgumentException - If null, more than 25 subcommands, or duplicate subcommand names are provided.
    • addSubcommands

      @Nonnull public SubcommandGroupData addSubcommands(@Nonnull Collection<? extends SubcommandData> subcommands)
      Add up to 25 Subcommands to this group.
      Parameters:
      subcommands - The subcommands to add
      Returns:
      The SubcommandGroupData instance, for chaining
      Throws:
      IllegalArgumentException - If null, more than 25 subcommands, or duplicate subcommand names are provided.
    • toData

      @Nonnull public DataObject toData()
      Description copied from interface: SerializableData
      Serialized DataObject for this object.
      Specified by:
      toData in interface SerializableData
      Returns:
      DataObject
    • fromData

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

      @Nonnull public static SubcommandGroupData fromGroup(@Nonnull Command.SubcommandGroup group)
      Converts the provided Command.SubcommandGroup into a SubcommandGroupData instance.
      Parameters:
      group - The subcommand group to convert
      Returns:
      An instance of SubcommandGroupData
      Throws:
      IllegalArgumentException - If null is provided or the subcommand group has illegal configuration