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 booleancompareContextCommands(net.dv8tion.jda.api.interactions.commands.Command cmd, ContextCommand<?> data) Takes aCommandobject that wraps a context-command and compares it to aContextCommandobject.static booleancompareSlashCommands(net.dv8tion.jda.api.interactions.commands.Command cmd, SlashCommand data) Takes aCommandobject that wraps aSlashCommandDataobject and compares it to aSlashCommandobject.static booleanequals(net.dv8tion.jda.api.utils.data.DataObject data, net.dv8tion.jda.api.utils.data.DataObject other) Compares twoDataObject.static Pair<Set<SlashCommand>,Set<ContextCommand<?>>> filterByType(Pair<Set<SlashCommand>, Set<ContextCommand<?>>> pair, RegistrationType type) Removes all elements of the providedPairwhich don't match the givenRegistrationType.static StringgetAsMention(SlashCommand command) Gets the mention from aSlashCommand.static StringgetAsMention(SlashCommand.Subcommand command) Gets the mention from aSlashCommand.Subcommand.static StringgetNames(Set<ContextCommand<?>> command, Set<SlashCommand> slash) Builds a formatted string out of the given sets of CommandData.
-
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 twoDataObject.- Parameters:
data- TheDataObject.other- The otherDataObject.- Returns:
- Whether both
DataObjectshare the same properties. - Since:
- v1.6
-
compareSlashCommands
public static boolean compareSlashCommands(@Nonnull net.dv8tion.jda.api.interactions.commands.Command cmd, @Nonnull SlashCommand data) Takes aCommandobject that wraps aSlashCommandDataobject and compares it to aSlashCommandobject.- Parameters:
cmd- TheCommandthat wraps aSlashCommandDataobject.data- TheSlashCommandto 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 aCommandobject that wraps a context-command and compares it to aContextCommandobject.- Parameters:
cmd- TheCommandthat wraps a context-command.data- TheContextCommandto compare two.- Returns:
- true if both are identical.
-
buildCommandPath
Used to create one command name out of the SlashCommand, SlashSubCommandGroup and SlashSubCommand- Parameters:
args- the arguments asStrings 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 ofContextCommands.slash- A set ofSlashCommands.- 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 providedPairwhich don't match the givenRegistrationType.- Parameters:
pair- ThePair.type- TheRegistrationType.- Returns:
- The modified
Pair. - Since:
- v1.5.2
-
getAsMention
Gets the mention from aSlashCommand.- Parameters:
command- theSlashCommandyou want the mention from.- Returns:
- the mention as a
String. - Since:
- v1.6
-
getAsMention
Gets the mention from aSlashCommand.Subcommand.- Parameters:
command- theSlashCommand.Subcommandyou want the mention from.- Returns:
- the mention as a
String. - Since:
- v1.6
-