Class DiscordResolver

java.lang.Object
de.chojo.jdautil.parsing.DiscordResolver

public class DiscordResolver extends Object
Class which can be used to resolve different discord entities from strings.
  • Constructor Details

    • DiscordResolver

      public DiscordResolver()
  • Method Details

    • getTextChannel

      public static Optional<TextChannel> getTextChannel(Guild guild, String channelString)
      Get a text channels by a list of id or name.
      Parameters:
      guild - guild for lookup
      channelString - id or name
      Returns:
      text channel or null
    • getValidRoles

      public static List<Role> getValidRoles(Guild guild, List<String> args)
      Returns from a list of role ids all valid roles.
      Parameters:
      guild - guild for role lookup
      args - array of role id
      Returns:
      list of valid roles
    • getValidRoles

      public static List<Role> getValidRoles(Guild guild, String[] args)
      Returns from a list of role ids all valid roles.
      Parameters:
      guild - guild for role lookup
      args - array of role ids
      Returns:
      list of valid roles
    • getValidTextChannels

      public static List<TextChannel> getValidTextChannels(Guild guild, List<String> args)
      Returns from a list of text channels ids all valid channels.
      Parameters:
      guild - guild for role lookup
      args - array of role id
      Returns:
      list of valid roles
    • getValidTextChannels

      public static List<TextChannel> getValidTextChannels(Guild guild, String[] args)
      Returns from a list of text channel ids all valid channels.
      Parameters:
      guild - guild for channel lookup
      args - array of channel ids
      Returns:
      list of valid channels
    • getValidTextChannelsById

      public static List<TextChannel> getValidTextChannelsById(Guild guild, List<Long> ids)
      Returns from a list of text channel ids all valid channels.
      Parameters:
      guild - guild for channel lookup
      ids - array of channel ids
      Returns:
      list of valid channels
    • getValidUserByLong

      public static List<User> getValidUserByLong(ShardManager shardManager, List<Long> collect)
      Get the valid users by id.
      Parameters:
      shardManager - jda for user lookup
      collect - list of long ids
      Returns:
      list of valid users.
    • getGuildChannel

      public static Optional<GuildChannel> getGuildChannel(Guild guild, String content)
    • getGuildUser

      public static Optional<User> getGuildUser(Guild guild, String userString)
      Get a user object by id, tag or name.
      Parameters:
      guild - guild for lookup
      userString - string for lookup
      Returns:
      user object if user is present or null
    • getGuildMember

      public static Optional<Member> getGuildMember(Guild guild, String memberString)
      Get a member object from a guild member by id, tag, nickname or effective name.
      Parameters:
      guild - guild for lookup
      memberString - string for lookup
      Returns:
      member object of member is present or null
    • getTextChannels

      public static List<TextChannel> getTextChannels(Guild guild, Collection<String> channelStrings)
      Get a text channels by a list of ids and/or names.
      Parameters:
      guild - guild for lookup
      channelStrings - list of ids and/or names
      Returns:
      list of text channels without null objects
    • getRoles

      public static List<Role> getRoles(Guild guild, Collection<String> roleStrings)
      Get roles from a list of role ids and/or names.
      Parameters:
      guild - guild for lookup
      roleStrings - list of ids and/or names
      Returns:
      list of roles. without null objects
    • getRole

      public static Optional<Role> getRole(Guild guild, String roleString)
      Get a role from id or name.
      Parameters:
      guild - guild for lookup
      roleString - id or name of role
      Returns:
      role object or null
    • getGuildMembers

      public static List<Member> getGuildMembers(Guild guild, Collection<String> memberStrings)
      Get guild member objects by a list of ids, tags, nickname or effective name.
      Parameters:
      guild - guild for lookup
      memberStrings - list of member ids, tags, nicknames or effective names
      Returns:
      list of member object without nulls
    • getGuildUsers

      public static List<User> getGuildUsers(Guild guild, Collection<String> userStrings)
      Get user objects which are valid on the guild by a list of ids, tags, or name.
      Parameters:
      guild - guild for lookup
      userStrings - list of user ids, names and/or tags
      Returns:
      list of users without null
    • fuzzyGuildUserSearch

      public static List<WeightedEntry<Member>> fuzzyGuildUserSearch(Guild guild, String userString)
      Search a user by fuzzy search on a guild.
      Parameters:
      guild - guild to search
      userString - user string to search
      Returns:
      a list of users. if a direct match was found only 1 user. if guild id is invalid a empty list is returned.
    • fuzzyGuildTargetSearch

      public static List<WeightedEntry<Member>> fuzzyGuildTargetSearch(String userString, Collection<Member> targets)
      Search a user by fuzzy search on a guild.
      Parameters:
      userString - user string to search
      targets - possible targets
      Returns:
      a list of users. if a direct match was found only 1 user. if guild id is invalid a empty list is returned.
    • getUserDeepSearch

      public static Optional<User> getUserDeepSearch(ShardManager shardManager, String userString, Guild guild)
      Searches for a user. First on a guild and after this on all users the bot currently know. Equal to calling getGuildUser(Guild, String) and getUser(ShardManager, String).
      Parameters:
      userString - string for lookup
      guild - guild for lookup
      Returns:
      user object or null if no user is found
    • getUser

      public static Optional<User> getUser(ShardManager shardManager, String userString)
      Get a user object by id, name or tag.
      Parameters:
      userString - string for lookup
      Returns:
      user object or null if no user is found
    • getUsers

      public static List<User> getUsers(ShardManager shardManager, Collection<String> userStrings)
      Get user objects from a list of ids, names and/or tags.
      Parameters:
      userStrings - list of ids, names and/or tags
      Returns:
      a list of user objects. without null
    • getGuilds

      public static List<Guild> getGuilds(ShardManager shardManager, List<String> guildStrings)
      Get guilds by ids or names.
      Parameters:
      guildStrings - list of ids and/or names.
      Returns:
      list of guilds. without null
    • getGuild

      public static Optional<Guild> getGuild(ShardManager shardManager, String guildString)
      Get guilds by id or name.
      Parameters:
      guildString - guild id or name
      Returns:
      guild object or null
    • fuzzyGlobalUserSearch

      public static List<User> fuzzyGlobalUserSearch(ShardManager shardManager, String userString)
      Search a user by fuzzy search.
      Parameters:
      userString - user string to search
      Returns:
      a list of users. if a direct match was found only