Package xyz.dynxsty.dih4jda.util
Class CommandUtils
java.lang.Object
xyz.dynxsty.dih4jda.util.CommandUtils
A utility class that contains some useful methods regarding command data.
- Since:
- v1.3
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildCommandPath(String... args) Used to create one command name out of the SlashCommand, SlashSubCommandGroup and SlashSubCommandstatic booleanequals(net.dv8tion.jda.api.interactions.commands.build.CommandData data, net.dv8tion.jda.api.interactions.commands.build.CommandData command, boolean isGlobalCommand) Compares twoCommandData(Context Command) objects.static booleanequals(net.dv8tion.jda.api.interactions.commands.build.OptionData data, net.dv8tion.jda.api.interactions.commands.build.OptionData option) Compares twoOptionDataobjects.static booleanequals(net.dv8tion.jda.api.interactions.commands.build.SlashCommandData data, net.dv8tion.jda.api.interactions.commands.build.SlashCommandData command, boolean isGlobalCommand) Compares twoSlashCommandData(Slash Command) objects.static booleanequals(net.dv8tion.jda.api.interactions.commands.build.SubcommandData data, net.dv8tion.jda.api.interactions.commands.build.SubcommandData subcommand) Compares twoSubcommandDataobjects.static booleanequals(net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData data, net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData group) Compares twoSubcommandGroupDataobjects.static booleanequals(net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions data, net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions command) Compares twoDefaultMemberPermissionsobjects.static Pair<Set<UnqueuedSlashCommandData>,Set<UnqueuedCommandData>> filterByType(Pair<Set<UnqueuedSlashCommandData>, Set<UnqueuedCommandData>> pair, RegistrationType type) Removes all elements of the providedPairwhich don't match the givenRegistrationType.static StringgetNames(Set<UnqueuedCommandData> command, Set<UnqueuedSlashCommandData> slash) Builds a formatted string out of the given sets of CommandData.static booleanisEqual(net.dv8tion.jda.api.interactions.commands.Command command, Object data, boolean isGlobalCommand) Checks if theCommandis equal to the givenCommandData.
-
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 twoSlashCommandData(Slash Command) objects.- Parameters:
data- TheSlashCommandDatacommand- The otherSlashCommandDataobject.- Returns:
- Whether both
SlashCommandDataobjects 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 twoCommandData(Context Command) objects.- Parameters:
data- TheCommandDatacommand- The otherCommandDataobject.- Returns:
- Whether both
CommandDataobjects 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 twoDefaultMemberPermissionsobjects.- Parameters:
data- TheDefaultMemberPermissions.command- The otherDefaultMemberPermissionsobject.- Returns:
- Whether both
DefaultMemberPermissionsobjects 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 twoSubcommandDataobjects.- Parameters:
data- TheSubcommandDatasubcommand- The otherSubcommandDataobject.- Returns:
- Whether both
SubcommandDataobjects 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 twoSubcommandGroupDataobjects.- Parameters:
data- TheSubcommandGroupDatagroup- The otherSubcommandGroupDataobject.- Returns:
- Whether both
SubcommandGroupDataobjects 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 twoOptionDataobjects.- Parameters:
data- TheOptionDataoption- The otherOptionDataobject.- Returns:
- Whether both
OptionDataobjects 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 theCommandis equal to the givenCommandData.- Parameters:
command- TheCommand.data- TheCommandData.- Returns:
- Whether the given Command originates from the given CommandData.
- Since:
- v1.5
-
buildCommandPath
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 ofUnqueuedCommandData.slash- A set ofUnqueuedSlashCommandData.- Returns:
- The formatted String.
- Since:
- v1.5
-
filterByType
@Nonnull public static Pair<Set<UnqueuedSlashCommandData>,Set<UnqueuedCommandData>> filterByType(Pair<Set<UnqueuedSlashCommandData>, Set<UnqueuedCommandData>> pair, RegistrationType type) Removes all elements of the providedPairwhich don't match the givenRegistrationType.- Parameters:
pair- ThePair.type- TheRegistrationType.- Returns:
- The modified
Pair. - Since:
- v1.5.2
-