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 String
buildCommandPath
(String... args) Used to create one command name out of the SlashCommand, SlashSubCommandGroup and SlashSubCommandstatic boolean
compareContextCommands
(net.dv8tion.jda.api.interactions.commands.Command cmd, ContextCommand<?> data) Takes aCommand
object that wraps a context-command and compares it to aContextCommand
object.static boolean
compareSlashCommands
(net.dv8tion.jda.api.interactions.commands.Command cmd, SlashCommand data) Takes aCommand
object that wraps aSlashCommandData
object and compares it to aSlashCommand
object.static boolean
equals
(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 providedPair
which don't match the givenRegistrationType
.static String
getAsMention
(SlashCommand command) Gets the mention from aSlashCommand
.static String
getAsMention
(SlashCommand.Subcommand command) Gets the mention from aSlashCommand.Subcommand
.static String
getNames
(Set<ContextCommand<?>> command, Set<SlashCommand> slash) Builds a formatted string out of the given sets of CommandData.static boolean
shouldBeRegistered
(net.dv8tion.jda.api.entities.Guild guild, BaseApplicationCommand<?, ?> command) Checks if a command should be registered on a specific guild.
-
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
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 aCommand
object that wraps aSlashCommandData
object and compares it to aSlashCommand
object.- Parameters:
cmd
- TheCommand
that wraps aSlashCommandData
object.data
- TheSlashCommand
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 aCommand
object that wraps a context-command and compares it to aContextCommand
object.- Parameters:
cmd
- TheCommand
that wraps a context-command.data
- TheContextCommand
to 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 asString
s 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 ofContextCommand
s.slash
- A set ofSlashCommand
s.- 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 providedPair
which don't match the givenRegistrationType
.- Parameters:
pair
- ThePair
.type
- TheRegistrationType
.- 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
- TheGuild
to check.command
- TheBaseApplicationCommand
to check.- Returns:
- true if the command should be registered.
- Since:
- v1.7
-
getAsMention
Gets the mention from aSlashCommand
.- Parameters:
command
- theSlashCommand
you want the mention from.- Returns:
- the mention as a
String
. - Since:
- v1.6
-
getAsMention
Gets the mention from aSlashCommand.Subcommand
.- Parameters:
command
- theSlashCommand.Subcommand
you want the mention from.- Returns:
- the mention as a
String
. - Since:
- v1.6
-