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 boolean
checkSignature
(MethodDescription method, Collection<Class<?>> methodSignature) static @NotNull ErrorMessageFactory.ErrorContext
errorContext
(@NotNull GenericInteractionCreateEvent event, @NotNull InteractionDefinition definition) static boolean
isIncorrectParameterType
(@NotNull MethodDescription method, int index, @NotNull Class<?> type) Checks if the given parameter is present at theMethod
at the given index.permissions
(@NotNull MethodBuildContext context) Extracts the permissions from aMethodBuildContext
.static @NotNull Optional
<GuildChannel> resolveGuildChannel
(@NotNull String raw, @NotNull GenericInteractionCreateEvent event) Attempts to resolve aGuildChannel
based on user input.static @NotNull String
sanitizeMention
(@NotNull String mention) Sanitizes a String containing a raw mention.
-
Constructor Details
-
Helpers
public Helpers()
-
-
Method Details
-
sanitizeMention
Sanitizes a String containing a raw mention. This will remove all markdown characters namely<
,@
,#
,&
,!
,>
. For instance:<@!393843637437464588>
gets sanitized to393843637437464588
.- Parameters:
mention
- the raw String to sanitize- Returns:
- the sanitized String
-
resolveGuildChannel
@NotNull public static @NotNull Optional<GuildChannel> resolveGuildChannel(@NotNull @NotNull String raw, @NotNull @NotNull GenericInteractionCreateEvent event) Attempts to resolve aGuildChannel
based on user input.- Parameters:
raw
- the String theGuildChannel
should be resolved fromevent
- the correspondingGenericInteractionCreateEvent
- Returns:
- an
Optional
holding the resolvedGuildChannel
or an emptyOptional
if the resolving failed
-
permissions
@NotNull public static @NotNull Set<String> permissions(@NotNull @NotNull MethodBuildContext context) 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
-
isIncorrectParameterType
public static boolean isIncorrectParameterType(@NotNull @NotNull MethodDescription method, int index, @NotNull @NotNull Class<?> type) Checks if the given parameter is present at theMethod
at the given index.- Parameters:
method
- theMethod
to checkindex
- the index the parameter is expected to be attype
- the type of the parameter- Returns:
true
if the parameter is present
-
checkSignature
public static boolean checkSignature(MethodDescription method, Collection<Class<?>> methodSignature) -
errorContext
@NotNull public static @NotNull ErrorMessageFactory.ErrorContext errorContext(@NotNull @NotNull GenericInteractionCreateEvent event, @NotNull @NotNull InteractionDefinition definition)
-