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.Command command, Object data, boolean isGlobalCommand) Checks if theCommandis equal to the givenCommandData.static booleanequals(net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions data, net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions command) Compares twoDefaultMemberPermissionsobjects.static booleanequals(net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap data, net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap command) Compares toLocalizationMapobjects.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.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.isGlobalCommand- aBooleanthat is ture if the provided commands are global commands else false.- 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.isGlobalCommand- aBooleanthat is ture if the provided commands are global commands else false.- 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.localization.LocalizationMap data, @Nonnull net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap command) Compares toLocalizationMapobjects.- Parameters:
data- TheLocalizationMap.command- The otherLocalizationMapobject.- Returns:
- Whether both
LocalizationMapobjects 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 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
-
equals
public static boolean equals(@Nonnull net.dv8tion.jda.api.interactions.commands.Command command, Object data, boolean isGlobalCommand) Checks if theCommandis equal to the givenCommandData.- Parameters:
command- TheCommand.data- TheCommandData.isGlobalCommand- aBooleanthat 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
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, 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.
-
getAsMention
Gets the mention from aSlashCommand.Subcommand.- Parameters:
command- theSlashCommand.Subcommandyou want the mention from.- Returns:
- the mention as a
String.
-