Class ComponentResolver<T extends net.dv8tion.jda.api.components.Component>

java.lang.Object
io.github.kaktushose.jdac.message.resolver.ComponentResolver<T>
Type Parameters:
T - a subtype of Component to resolve
All Implemented Interfaces:
Resolver<T>

public final class ComponentResolver<T extends net.dv8tion.jda.api.components.Component> extends Object implements Resolver<T>

Resolver implementation that can resolve any Component. This will only resolve the textual fields of components, namely:

  • content
  • label
  • placeholder
  • value

As with other Resolvers, this class is not intended to be directly used by end users but part of the public api to allow manual execution of the frameworks resolving logic for dynamic values if needed.

  • Constructor Details

    • ComponentResolver

      public ComponentResolver(Resolver<String> resolver, Class<T> type)
      Constructs a new ComponentResolver.
      Parameters:
      resolver - a Resolver capable of resolving Strings
      type - the Component Class, needed for deserialization
  • Method Details

    • resolve

      public Collection<T> resolve(Collection<T> components, Locale locale, Map<String, @Nullable Object> placeholders)
      Resolves a Collection of Components. FileUploads will be preserved.
      Parameters:
      components - the Components to resolve
      locale - the Locale to use for localization
      placeholders - the placeholders to use if supported by the used String Resolver
      Returns:
      the Collection of resolved Components
    • resolve

      public T resolve(T component, Locale locale, Map<String, @Nullable Object> placeholders)
      Resolves a Component. FileUploads will be preserved.
      Specified by:
      resolve in interface Resolver<T extends net.dv8tion.jda.api.components.Component>
      Parameters:
      component - the Component to resolve
      locale - the Locale to use for localization
      placeholders - the placeholders to use if supported by the used String Resolver
      Returns:
      the resolved Component
    • priority

      public int priority()
      Description copied from interface: Resolver

      The priority of this resolver influences the order in which resolver are applied in a resolution pipeline.

      Currently, this only applies to Resolver<String>, when using MessageResolver (as JDA-Commands does internally). Generally speaking, resolvers with lower priority run first.

      If the priority isn't important (e.g. for ComponentResolver) this should return 0.

      Specified by:
      priority in interface Resolver<T extends net.dv8tion.jda.api.components.Component>
      Returns:
      0