Class CommandUtils

java.lang.Object
xyz.dynxsty.dih4jda.util.CommandUtils

public class CommandUtils extends Object
A utility class that contains some useful methods regarding command data.
Since:
v1.3
  • Method Details

    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.utils.data.DataObject data, @Nonnull net.dv8tion.jda.api.utils.data.DataObject other)
      Compares two DataObject.
      Parameters:
      data - The DataObject.
      other - The other DataObject.
      Returns:
      Whether both DataObject share the same properties.
      Since:
      v1.6
    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.Command command, @Nonnull Object data)
      Checks if the Command is equal to the given CommandData.
      Parameters:
      command - The Command.
      data - The CommandData.
      Returns:
      Whether the given Command originates from the given CommandData.
      Since:
      v1.5
    • buildCommandPath

      @Nonnull public static String buildCommandPath(@Nonnull String... args)
      Used to create one command name out of the SlashCommand, SlashSubCommandGroup and SlashSubCommand
      Parameters:
      args - the arguments as Strings you want to join together.
      Returns:
      One combined string.
      Since:
      v1.4
    • getNames

      @Nonnull public static String getNames(@Nonnull Set<ContextCommand<?>> command, @Nonnull Set<SlashCommand> slash)
      Builds a formatted string out of the given sets of CommandData.
      Parameters:
      command - A set of ContextCommands.
      slash - A set of SlashCommands.
      Returns:
      The formatted String.
      Since:
      v1.5
    • filterByType

      @Nonnull public static Pair<Set<SlashCommand>,Set<ContextCommand<?>>> filterByType(@Nonnull Pair<Set<SlashCommand>,Set<ContextCommand<?>>> pair, @Nonnull RegistrationType type)
      Removes all elements of the provided Pair which don't match the given RegistrationType.
      Parameters:
      pair - The Pair.
      type - The RegistrationType.
      Returns:
      The modified Pair.
      Since:
      v1.5.2
    • getAsMention

      @Nonnull public static String getAsMention(@Nonnull SlashCommand command)
      Gets the mention from a SlashCommand.
      Parameters:
      command - the SlashCommand you want the mention from.
      Returns:
      the mention as a String.
      Since:
      v1.6
    • getAsMention

      @Nullable public static String getAsMention(@Nonnull SlashCommand.Subcommand command)
      Gets the mention from a SlashCommand.Subcommand.
      Parameters:
      command - the SlashCommand.Subcommand you want the mention from.
      Returns:
      the mention as a String.
      Since:
      v1.6