Class Helpers

java.lang.Object
com.github.kaktushose.jda.commands.internal.Helpers

@Internal public final class Helpers extends Object
Collection of helper methods that are used inside the framework.
  • Constructor Details

    • Helpers

      public Helpers()
  • Method Details

    • sanitizeMention

      @NotNull public static @NotNull String sanitizeMention(@NotNull @NotNull String mention)
      Sanitizes a String containing a raw mention. This will remove all markdown characters namely <, @, #, &, !, >. For instance: <@!393843637437464588> gets sanitized to 393843637437464588.
      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 a GuildChannel based on user input.
      Parameters:
      raw - the String the GuildChannel should be resolved from
      event - the corresponding GenericInteractionCreateEvent
      Returns:
      an Optional holding the resolved GuildChannel or an empty Optional if the resolving failed
    • permissions

      @NotNull public static @NotNull Set<String> permissions(@NotNull @NotNull MethodBuildContext context)
      Extracts the permissions from a MethodBuildContext. This combines the permissions of the method and the class.
      Parameters:
      context - the MethodBuildContext 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 the Method at the given index.
      Parameters:
      method - the Method to check
      index - the index the parameter is expected to be at
      type - 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)