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.Command command, Object data, boolean isGlobalCommand)
    Checks if the Command is equal to the given CommandData.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions data, net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions command)
    Compares two DefaultMemberPermissions objects.
    static boolean
    equals(net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap data, net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap command)
    Compares to LocalizationMap objects.
    Removes all elements of the provided Pair which don't match the given RegistrationType.
    static String
    Gets the mention from a SlashCommand.
    static String
    Gets the mention from a SlashCommand.Subcommand.
    static String
    getNames(Set<ContextCommand<?>> command, Set<SlashCommand> slash)
    Builds a formatted string out of the given sets of 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.
      isGlobalCommand - a Boolean that is ture if the provided commands are global commands else false.
      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.
      isGlobalCommand - a Boolean that is ture if the provided commands are global commands else false.
      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.localization.LocalizationMap data, @Nonnull net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap command)
      Compares to LocalizationMap objects.
      Parameters:
      data - The LocalizationMap.
      command - The other LocalizationMap object.
      Returns:
      Whether both LocalizationMap objects are equal.
      Since:
      v1.6
    • 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
    • equals

      public static boolean equals(@Nonnull 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.
      isGlobalCommand - a Boolean that is ture if the provided commands are global commands else false.
      Returns:
      Whether the given Command originates from the given CommandData.
      Since:
      v1.5
    • buildCommandPath

      @Nonnull public static String buildCommandPath(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, 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

      @Nullable 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.
    • 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.