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
    • compareSlashCommands

      public static boolean compareSlashCommands(@Nonnull net.dv8tion.jda.api.interactions.commands.Command cmd, @Nonnull SlashCommand data)
      Takes a Command object that wraps a SlashCommandData object and compares it to a SlashCommand object.
      Parameters:
      cmd - The Command that wraps a SlashCommandData object.
      data - The SlashCommand to compare two.
      Returns:
      true if both are identical.
      See Also:
    • compareContextCommands

      public static boolean compareContextCommands(@Nonnull net.dv8tion.jda.api.interactions.commands.Command cmd, @Nonnull ContextCommand<?> data)
      Takes a Command object that wraps a context-command and compares it to a ContextCommand object.
      Parameters:
      cmd - The Command that wraps a context-command.
      data - The ContextCommand to compare two.
      Returns:
      true if both are identical.
    • 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
    • shouldBeRegistered

      public static boolean shouldBeRegistered(@Nonnull net.dv8tion.jda.api.entities.Guild guild, @Nonnull BaseApplicationCommand<?,?> command)
      Checks if a command should be registered on a specific guild.
      Parameters:
      guild - The Guild to check.
      command - The BaseApplicationCommand to check.
      Returns:
      true if the command should be registered.
      Since:
      v1.7
    • 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