Class Helpers
java.lang.Object
com.github.kaktushose.jda.commands.internal.Helpers
Collection of helper methods that are used inside the framework.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkDetached
(IDetachableEntity entity, Class<?> origin) static void
checkParameterType
(MethodDescription method, int index, Class<?> type) Checks if the given parameter is present at theMethod
at the given index.static void
checkSignature
(MethodDescription method, SequencedCollection<Class<?>> methodSignature) commandConfig
(MethodBuildContext context) TheCommandDefinition.CommandConfig
that should be used when registering commands.errorContext
(GenericInteractionCreateEvent event, InteractionDefinition definition) static String
humanReadableType
(OptionMapping optionMapping) Gets the human-readable representation of anOptionMapping
.permissions
(MethodBuildContext context) Extracts the permissions from aMethodBuildContext
.replyConfig
(Invokable definition, InteractionDefinition.ReplyConfig fallback) TheInteractionDefinition.ReplyConfig
that should be used when sending replies.
-
Constructor Details
-
Helpers
public Helpers()
-
-
Method Details
-
humanReadableType
Gets the human-readable representation of anOptionMapping
.- Parameters:
optionMapping
- theOptionMapping
to return the human-readable representation for- Returns:
- the human-readable representation
-
permissions
Extracts the permissions from aMethodBuildContext
. This combines the permissions of the method and the class.- Parameters:
context
- theMethodBuildContext
to extract the permissions from- Returns:
- a possibly-empty set of all permissions
-
checkParameterType
-
checkSignature
public static void checkSignature(MethodDescription method, SequencedCollection<Class<?>> methodSignature) -
checkDetached
-
replyConfig
public static InteractionDefinition.ReplyConfig replyConfig(Invokable definition, InteractionDefinition.ReplyConfig fallback) TheInteractionDefinition.ReplyConfig
that should be used when sending replies.- Parameters:
definition
- theinteraction definition
to build theInteractionDefinition.ReplyConfig
fromfallback
- theInteractionDefinition.ReplyConfig
to use as a fallback- Implementation Note:
- This will first attempt to use the
ReplyConfig
annotation of the method and then of the class. If neither is present will fall back to the globalInteractionDefinition.ReplyConfig
provided byJDACBuilder
.
-
commandConfig
TheCommandDefinition.CommandConfig
that should be used when registering commands.- Parameters:
context
- theMethodBuildContext
to build theCommandDefinition.CommandConfig
from- Implementation Note:
- This will first attempt to use the
CommandConfig
annotation of the method and then of the class. If neither is present will fall back to the globalCommandDefinition.CommandConfig
provided byJDACBuilder
.
-
errorContext
public static ErrorMessageFactory.ErrorContext errorContext(GenericInteractionCreateEvent event, InteractionDefinition definition)
-