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 Summary

    Modifier and Type
    Method
    Description
    static String
    Used to create one command name out of the SlashCommand, SlashSubCommandGroup and SlashSubCommand
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.build.CommandData data, net.dv8tion.jda.api.interactions.commands.build.CommandData command, boolean isGlobalCommand)
    Compares two CommandData (Context Command) objects.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.build.OptionData data, net.dv8tion.jda.api.interactions.commands.build.OptionData option)
    Compares two OptionData objects.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.build.SlashCommandData data, net.dv8tion.jda.api.interactions.commands.build.SlashCommandData command, boolean isGlobalCommand)
    Compares two SlashCommandData (Slash Command) objects.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.build.SubcommandData data, net.dv8tion.jda.api.interactions.commands.build.SubcommandData subcommand)
    Compares two SubcommandData objects.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData data, net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData group)
    Compares two SubcommandGroupData objects.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions data, net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions command)
    Compares two DefaultMemberPermissions objects.
    Removes all elements of the provided Pair which don't match the given RegistrationType.
    static String
    Builds a formatted string out of the given sets of CommandData.
    static boolean
    isEqual(net.dv8tion.jda.api.interactions.commands.Command command, Object data, boolean isGlobalCommand)
    Checks if the Command is equal to the given CommandData.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.build.SlashCommandData data, @Nonnull net.dv8tion.jda.api.interactions.commands.build.SlashCommandData command, boolean isGlobalCommand)
      Compares two SlashCommandData (Slash Command) objects.
      Parameters:
      data - The SlashCommandData
      command - The other SlashCommandData object.
      Returns:
      Whether both SlashCommandData objects share the same properties.
      Since:
      v1.5
    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.build.CommandData data, @Nonnull net.dv8tion.jda.api.interactions.commands.build.CommandData command, boolean isGlobalCommand)
      Compares two CommandData (Context Command) objects.
      Parameters:
      data - The CommandData
      command - The other CommandData object.
      Returns:
      Whether both CommandData objects share the same properties.
      Since:
      v1.5
    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions data, @Nonnull net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions command)
      Compares two DefaultMemberPermissions objects.
      Parameters:
      data - The DefaultMemberPermissions.
      command - The other DefaultMemberPermissions object.
      Returns:
      Whether both DefaultMemberPermissions objects are equal.
      Since:
      v1.5.5
    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.build.SubcommandData data, @Nonnull net.dv8tion.jda.api.interactions.commands.build.SubcommandData subcommand)
      Compares two SubcommandData objects.
      Parameters:
      data - The SubcommandData
      subcommand - The other SubcommandData object.
      Returns:
      Whether both SubcommandData objects share the same properties.
      Since:
      v1.5
    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData data, @Nonnull net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData group)
      Compares two SubcommandGroupData objects.
      Parameters:
      data - The SubcommandGroupData
      group - The other SubcommandGroupData object.
      Returns:
      Whether both SubcommandGroupData objects share the same properties.
      Since:
      v1.5
    • equals

      public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.build.OptionData data, @Nonnull net.dv8tion.jda.api.interactions.commands.build.OptionData option)
      Compares two OptionData objects.
      Parameters:
      data - The OptionData
      option - The other OptionData object.
      Returns:
      Whether both OptionData objects share the same properties.
      Since:
      v1.5
    • isEqual

      public static boolean isEqual(net.dv8tion.jda.api.interactions.commands.Command command, Object data, boolean isGlobalCommand)
      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

      @Contract(pure=true) @Nonnull public static String buildCommandPath(String... args)
      Used to create one command name out of the SlashCommand, SlashSubCommandGroup and SlashSubCommand
      Returns:
      One combined string.
      Since:
      v1.4
    • getNames

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

      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