Class FinderUtil
Guilds, or locally to a specified Guild.
All methods use a similar priority hierarchy and return an immutable List based on the results.
The hierarchy is as follows:
- Special Cases: Specifics of these are described per individual method documentation.
Note that successful results from these are typicallya singleton list. - Direct ID: Query is a number with 17 or more digits, resembling an
SnowflakeID. - Exact Match: Query provided is an exact match (case sensitive and complete) to one or more entities.
- Wrong Case: Query provided is a case-insensitive, but exact, match to the entirety of one or more entities.
- Starting With: Query provided is an case-insensitive match to the beginning of one or more entities.
- Contains: Query provided is a case-insensitive match to a part of one or more entities.
Shard Manager Usage
Methods that query an instance of JDA always have two implementations:
- Global: Queries a
ShardManagerif one is available, or JDA if one is not. - Shard: Always queries the provided instance, and never a ShardManager, even if one is available.
Many of these utilities were inspired by and ported to JDA 3.X from Spectra's FinderUtil originally written by jagrosh in 2.X.
- Since:
- 1.3
- Author:
- Kaidan Gustave
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic List<net.dv8tion.jda.api.entities.User>findBannedUsers(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildfor a bannedUser.static List<net.dv8tion.jda.api.entities.channel.concrete.Category>findCategories(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforCategories.static List<net.dv8tion.jda.api.entities.channel.concrete.Category>findCategories(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforCategories.static List<net.dv8tion.jda.api.entities.emoji.Emoji>findEmotes(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforEmotes.static List<net.dv8tion.jda.api.entities.emoji.Emoji>findEmotes(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforEmojis.static List<net.dv8tion.jda.api.entities.Member>findMembers(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforMembers.static List<net.dv8tion.jda.api.entities.Role>Queries a providedGuildforRoles.static List<net.dv8tion.jda.api.entities.channel.concrete.Category>findShardCategories(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforCategories.static List<net.dv8tion.jda.api.entities.emoji.Emoji>findShardEmotes(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforEmotes.static List<net.dv8tion.jda.api.entities.channel.concrete.TextChannel>findShardTextChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforTextChannels.static List<net.dv8tion.jda.api.entities.User>findShardUsers(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforUsers.static List<net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel>findShardVoiceChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforVoiceChannels.static List<net.dv8tion.jda.api.entities.channel.concrete.TextChannel>findTextChannels(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforTextChannels.static List<net.dv8tion.jda.api.entities.channel.concrete.TextChannel>findTextChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforTextChannels.static List<net.dv8tion.jda.api.entities.User>Queries a provided instance ofJDAforUsers.static List<net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel>findVoiceChannels(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforVoiceChannels.static List<net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel>findVoiceChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforVoiceChannels.
-
Field Details
-
DISCORD_ID
-
FULL_USER_REF
-
USER_MENTION
-
CHANNEL_MENTION
-
ROLE_MENTION
-
EMOTE_MENTION
-
-
Method Details
-
findUsers
public static List<net.dv8tion.jda.api.entities.User> findUsers(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforUsers.If a
ShardManageris available this will query across that instead of the JDA instance.The following special cases are applied in order of listing before the standard search is done:
- User Mention: Query provided matches an @user mention (more specifically <@userID>).
- Full User Reference: Query provided matches a full Username#XXXX reference.
NOTE: this can return a list with more than one entity.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof Users found by the query from the provided JDA instance.
-
findShardUsers
public static List<net.dv8tion.jda.api.entities.User> findShardUsers(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforUsers.This only queries the instance of JDA, regardless of whether or not a
ShardManageris available.The following special cases are applied in order of listing before the standard search is done:
- User Mention: Query provided matches an @user mention (more specifically <@userID>).
- Full User Reference: Query provided matches a full Username#XXXX reference.
NOTE: this can return a list with more than one entity.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof Users found by the query from the provided JDA instance.
-
findBannedUsers
public static List<net.dv8tion.jda.api.entities.User> findBannedUsers(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildfor a bannedUser.The following special cases are applied in order of listing before the standard search is done:
- User Mention: Query provided matches an @user mention (more specifically <@userID>).
- Full User Reference: Query provided matches a full Username#XXXX reference.
NOTE: this can return a list with more than one entity.
WARNING
Unlike the other finder methods, this one has two very unique features that set it apart from the rest:
- 1) In order to get a list of bans that is usable, this method initial retrieves it by usage of
Guild#getBans().complete(). Because of this, as would be the same expected effect from the other utility methods, this will block the thread it is called in. The difference, however, comes in that this method may have slight variations in return speed, especially when put under higher usage over a shorter period of time. - 2) This method can return
nullif and only if anExceptionis thrown while initially getting banned Users viaGuild#getBanList().
-
findMembers
public static List<net.dv8tion.jda.api.entities.Member> findMembers(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforMembers.The following special cases are applied in order of listing before the standard search is done:
- User Mention: Query provided matches an @user mention (more specifically <@userID> or <@!userID>).
- Full User Reference: Query provided matches a full Username#XXXX reference.
NOTE: this can return a list with more than one entity.
Unlike
FinderUtil.findUsers(String, JDA), this method queries based on two different names: user name and effective name (excluding special cases in which it queries solely based on user name).
Each standard check looks at the user name, then the member name, and if either one's criteria is met the Member is added to the returned list. This is important to note, because the returned list may contain exact matches for User's name as well as exact matches for a Member's effective name, with nothing guaranteeing the returns will be exclusively containing matches for one or the other.
Information on effective name can be found inMember#getEffectiveName().- Parameters:
query- The String query to search byguild- The Guild to search from- Returns:
- A possibly empty
Listof Members found by the query from the provided Guild.
-
findTextChannels
public static List<net.dv8tion.jda.api.entities.channel.concrete.TextChannel> findTextChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforTextChannels.If a
ShardManageris available this will query across that instead of the JDA instance.The following special case is applied before the standard search is done:
- Channel Mention: Query provided matches a #channel mention (more specifically <#channelID>)
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof TextChannels found by the query from the provided JDA instance.
-
findShardTextChannels
public static List<net.dv8tion.jda.api.entities.channel.concrete.TextChannel> findShardTextChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforTextChannels.This only queries the instance of JDA, regardless of whether or not a
ShardManageris available.The following special case is applied before the standard search is done:
- Channel Mention: Query provided matches a #channel mention (more specifically <#channelID>)
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof TextChannels found by the query from the provided JDA instance.
-
findTextChannels
public static List<net.dv8tion.jda.api.entities.channel.concrete.TextChannel> findTextChannels(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforTextChannels.The following special case is applied before the standard search is done:
- Channel Mention: Query provided matches a #channel mention (more specifically <#channelID>)
- Parameters:
query- The String query to search byguild- The Guild to search from- Returns:
- A possibly-empty
Listof TextChannels found by the query from the provided Guild.
-
findVoiceChannels
public static List<net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel> findVoiceChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforVoiceChannels.If a
ShardManageris available this will query across that instead of the JDA instance.The standard search does not follow any special cases.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof VoiceChannels found by the query from the provided JDA instance.
-
findShardVoiceChannels
public static List<net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel> findShardVoiceChannels(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforVoiceChannels.This only queries the instance of JDA, regardless of whether or not a
ShardManageris available.The standard search does not follow any special cases.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof VoiceChannels found by the query from the provided JDA instance.
-
findVoiceChannels
public static List<net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel> findVoiceChannels(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforVoiceChannels.The standard search does not follow any special cases.
- Parameters:
query- The String query to search byguild- The Guild to search from- Returns:
- A possibly-empty
Listof VoiceChannels found by the query from the provided Guild.
-
findCategories
public static List<net.dv8tion.jda.api.entities.channel.concrete.Category> findCategories(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforCategories.If a
ShardManageris available this will query across that instead of the JDA instance.The standard search does not follow any special cases.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof Categories found by the query from the provided JDA instance.
-
findShardCategories
public static List<net.dv8tion.jda.api.entities.channel.concrete.Category> findShardCategories(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforCategories.This only queries the instance of JDA, regardless of whether or not a
ShardManageris available.The standard search does not follow any special cases.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof Categories found by the query from the provided JDA instance.
-
findCategories
public static List<net.dv8tion.jda.api.entities.channel.concrete.Category> findCategories(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforCategories.The standard search does not follow any special cases.
- Parameters:
query- The String query to search byguild- The Guild to search from- Returns:
- A possibly-empty
Listof Categories found by the query from the provided Guild.
-
findRoles
public static List<net.dv8tion.jda.api.entities.Role> findRoles(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforRoles.The following special case is applied before the standard search is done:
- Role Mention: Query provided matches a @role mention (more specifically <@&roleID>)
- Parameters:
query- The String query to search byguild- The Guild to search from- Returns:
- A possibly-empty
Listof Roles found by the query from the provided Guild.
-
findEmotes
public static List<net.dv8tion.jda.api.entities.emoji.Emoji> findEmotes(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforEmojis.If a
ShardManageris available this will query across that instead of the JDA instance.The following special case is applied before the standard search is done:
- Emote Mention: Query provided matches a :emote: mention (more specifically <:emoteName:emoteID>).
Note: This only returns here if the emote is valid. Validity being the ID retrieves a non-null Emote and that thenameof the Emote is equal to the name found in the query.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof Emotes found by the query from the provided JDA instance.
- Emote Mention: Query provided matches a :emote: mention (more specifically <:emoteName:emoteID>).
-
findShardEmotes
public static List<net.dv8tion.jda.api.entities.emoji.Emoji> findShardEmotes(String query, net.dv8tion.jda.api.JDA jda) Queries a provided instance ofJDAforEmotes.This only queries the instance of JDA, regardless of whether or not a
ShardManageris available.The following special case is applied before the standard search is done:
- Emote Mention: Query provided matches a :emote: mention (more specifically <:emoteName:emoteID>).
Note: This only returns here if the emote is valid. Validity being the ID retrieves a non-null Emote and that thenameof the Emote is equal to the name found in the query.
- Parameters:
query- The String query to search byjda- The instance of JDA to search from- Returns:
- A possibly-empty
Listof Emotes found by the query from the provided JDA instance.
- Emote Mention: Query provided matches a :emote: mention (more specifically <:emoteName:emoteID>).
-
findEmotes
public static List<net.dv8tion.jda.api.entities.emoji.Emoji> findEmotes(String query, net.dv8tion.jda.api.entities.Guild guild) Queries a providedGuildforEmotes.The following special case is applied before the standard search is done:
- Emote Mention: Query provided matches a :emote: mention (more specifically <:emoteName:emoteID>).
Note: This only returns here if the emote is valid. Validity being the ID retrieves a non-null Emote and that thenameof the Emote is equal to the name found in the query.
- Parameters:
query- The String query to search byguild- The Guild to search from- Returns:
- A possibly-empty
Listof Emotes found by the query from the provided Guild.
- Emote Mention: Query provided matches a :emote: mention (more specifically <:emoteName:emoteID>).
-