Class EmojiResolver

java.lang.Object
io.github.kaktushose.jdac.message.emoji.EmojiResolver
All Implemented Interfaces:
Resolver<String>

public final class EmojiResolver extends Object implements Resolver<String>

The EmojiResolver replaces emoji aliases in strings with their formatted value.

An emoji alias is just the discord alias (either Unicode oder app emoji) enclosed by a colon :. For example the Unicode alias :joy: will be replaced by 😂 and the app emoji :app_emote: by its uploaded file.

Normally it shouldn't be necessary to escape the colons in messages (that shouldn't be an emoji alias), but in case any troubles occur you can just prefix it with \ (in java \\) to escape it.

Supported are all discord emojis, their skin tone variants and the app emotes for this bot. App emotes with the same name as a Unicode one will override later.

  • Constructor Details

    • EmojiResolver

      public EmojiResolver(Collection<ApplicationEmoji> applicationEmojis)
      Constructs a new instance of EmojiResolver with the given application emojis and all Unicode emojis supported by discord. If one of the passed application emojis has the same alias as a Unicode emoji, the app emojis takes precedence.
      Parameters:
      applicationEmojis - a list of all application emojis of this bot
  • Method Details

    • resolve

      public String resolve(String msg)
      Resolves the emoji aliases of a string according to the javadocs of this class.
      Parameters:
      msg - The string to be resolved
      Returns:
      the resolved string
    • resolve

      public String resolve(String msg, Locale locale, Map<String, @Nullable Object> placeholders)
      Description copied from interface: Resolver
      Resolves the given object for the provided locale.
      Specified by:
      resolve in interface Resolver<String>
      Parameters:
      msg - the object to resolve
      locale - the Locale to use for localization
      placeholders - the placeholders to use if supported by the used localization system
      Returns:
      the resolved object
    • 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<String>
      Returns:
      3000