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 booleanChecks if theCommandis equal to the givenCommandData.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
-
equals
public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.Command command, @Nonnull Object data) 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- 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
-