public final class JDAUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static @Nullable net.dv8tion.jda.api.entities.channel.ChannelType |
channelType(@NotNull java.lang.Class<? extends net.dv8tion.jda.api.entities.channel.Channel> channelInterface)
Returns the
ChannelType that corresponds to the given channel interface |
static <A extends revxrsal.commands.command.CommandActor> |
findCommand(@NotNull revxrsal.commands.Lamp<A> lamp,
@NotNull java.lang.String fullPath,
@NotNull java.util.List<net.dv8tion.jda.api.interactions.commands.OptionMapping> options)
Finds the most suitable
ExecutableCommand from the given path and options |
static <A extends revxrsal.commands.command.CommandActor> |
fromOption(@NotNull net.dv8tion.jda.api.interactions.commands.OptionMapping option,
@NotNull revxrsal.commands.node.ParameterNode<A,?> parameter)
Parses the object inside the
OptionMapping safely to be
fed into a ParameterNode |
static <A extends revxrsal.commands.command.CommandActor> |
getRequiredPath(@NotNull revxrsal.commands.command.ExecutableCommand<A> command)
Returns the required literal path of the given command.
|
static @NotNull net.dv8tion.jda.api.interactions.commands.Command.Choice |
toChoice(@NotNull java.lang.String suggestion,
@NotNull net.dv8tion.jda.api.interactions.commands.OptionType type)
Maps the given suggestion to a
Command.Choice. |
static @NotNull java.util.List<net.dv8tion.jda.api.interactions.commands.Command.Choice> |
toChoices(@NotNull java.util.Collection<java.lang.String> suggestions,
@NotNull net.dv8tion.jda.api.interactions.commands.OptionType type)
Maps the given list of suggestions to a list of
Command.Choices. |
static <A extends SlashCommandActor> |
toOptionData(@NotNull revxrsal.commands.node.ParameterNode<A,java.lang.Object> parameter)
Creates
OptionData from the given ParameterNode. |
static <A extends SlashCommandActor> |
toOptionType(revxrsal.commands.node.ParameterNode<A,java.lang.Object> parameter)
Finds a suitable
OptionType for the given ParameterNode. |
@NotNull
public static <A extends revxrsal.commands.command.CommandActor> @NotNull java.util.Optional<revxrsal.commands.command.ExecutableCommand<A>> findCommand(@NotNull
@NotNull revxrsal.commands.Lamp<A> lamp,
@NotNull
@NotNull java.lang.String fullPath,
@NotNull
@NotNull java.util.List<net.dv8tion.jda.api.interactions.commands.OptionMapping> options)
ExecutableCommand from the given path and optionsA - The actor typelamp - The Lamp instancefullPath - The full path of literalsoptions - The supplied list of optionsOptional.empty() if not found.@NotNull
public static <A extends revxrsal.commands.command.CommandActor> @NotNull java.lang.Object fromOption(@NotNull
@NotNull net.dv8tion.jda.api.interactions.commands.OptionMapping option,
@NotNull
@NotNull revxrsal.commands.node.ParameterNode<A,?> parameter)
OptionMapping safely to be
fed into a ParameterNodeA - The actor typeoption - The option to parse fromparameter - The parameter to adapt for@Contract(value="_ -> new",
pure=true)
@NotNull
public static <A extends SlashCommandActor> @NotNull net.dv8tion.jda.api.interactions.commands.build.OptionData toOptionData(@NotNull
@NotNull revxrsal.commands.node.ParameterNode<A,java.lang.Object> parameter)
OptionData from the given ParameterNode. This will respect
the following annotations:
If the parameter type is an enum, it will also use its values
as predefined choicesA - The actor typeparameter - The parameter to parse forOptionData.@NotNull public static <A extends SlashCommandActor> @NotNull net.dv8tion.jda.api.interactions.commands.OptionType toOptionType(revxrsal.commands.node.ParameterNode<A,java.lang.Object> parameter)
OptionType for the given ParameterNode. This will
never return null. In cases of an odd parameter type, this will return
an OptionType.STRING.A - The actor typeparameter - The parameter to find for@NotNull
public static @NotNull net.dv8tion.jda.api.interactions.commands.Command.Choice toChoice(@NotNull
@NotNull java.lang.String suggestion,
@NotNull
@NotNull net.dv8tion.jda.api.interactions.commands.OptionType type)
Command.Choice. This will convert it to
a double or integer if necessarysuggestion - Suggestion to maptype - The option type@NotNull
public static @NotNull java.util.List<net.dv8tion.jda.api.interactions.commands.Command.Choice> toChoices(@NotNull
@NotNull java.util.Collection<java.lang.String> suggestions,
@NotNull
@NotNull net.dv8tion.jda.api.interactions.commands.OptionType type)
Command.Choices. This will
convert them to doubles or integers if necessary.suggestions - Suggestions to maptype - The suggestions type@Contract(pure=true)
@NotNull
public static <A extends revxrsal.commands.command.CommandActor> @NotNull java.lang.String getRequiredPath(@NotNull
@NotNull revxrsal.commands.command.ExecutableCommand<A> command)
A - The actor typecommand - Command to get the path for@Nullable
public static @Nullable net.dv8tion.jda.api.entities.channel.ChannelType channelType(@NotNull
@NotNull java.lang.Class<? extends net.dv8tion.jda.api.entities.channel.Channel> channelInterface)
ChannelType that corresponds to the given channel interfacechannelInterface - The interface to check fornull if not found.