public final class FinderUtil
extends java.lang.Object
Guild
s, 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:
a singleton list
.Snowflake
ID.
Shard Manager Usage
Methods that query an instance of JDA
always have two implementations:
ShardManager
if one
is available, or JDA if one is not.Many of these utilities were inspired by and ported to JDA 3.X from Spectra's FinderUtil originally written by jagrosh in 2.X.
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
CHANNEL_MENTION |
static java.util.regex.Pattern |
DISCORD_ID |
static java.util.regex.Pattern |
EMOTE_MENTION |
static java.util.regex.Pattern |
FULL_USER_REF |
static java.util.regex.Pattern |
ROLE_MENTION |
static java.util.regex.Pattern |
USER_MENTION |
Modifier and Type | Method and Description |
---|---|
static java.util.List<net.dv8tion.jda.core.entities.User> |
findBannedUsers(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for a banned User . |
static java.util.List<net.dv8tion.jda.core.entities.Category> |
findCategories(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for
Categories . |
static java.util.List<net.dv8tion.jda.core.entities.Category> |
findCategories(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
Categories . |
static java.util.List<net.dv8tion.jda.core.entities.Emote> |
findEmotes(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for
Emote s. |
static java.util.List<net.dv8tion.jda.core.entities.Emote> |
findEmotes(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
Emote s. |
static java.util.List<net.dv8tion.jda.core.entities.Member> |
findMembers(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for Member s. |
static java.util.List<net.dv8tion.jda.core.entities.Role> |
findRoles(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for Role s. |
static java.util.List<net.dv8tion.jda.core.entities.Category> |
findShardCategories(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
Categories . |
static java.util.List<net.dv8tion.jda.core.entities.Emote> |
findShardEmotes(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
Emote s. |
static java.util.List<net.dv8tion.jda.core.entities.TextChannel> |
findShardTextChannels(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
TextChannel s. |
static java.util.List<net.dv8tion.jda.core.entities.User> |
findShardUsers(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for User s. |
static java.util.List<net.dv8tion.jda.core.entities.VoiceChannel> |
findShardVoiceChannels(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
VoiceChannel s. |
static java.util.List<net.dv8tion.jda.core.entities.TextChannel> |
findTextChannels(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for
TextChannel s. |
static java.util.List<net.dv8tion.jda.core.entities.TextChannel> |
findTextChannels(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
TextChannel s. |
static java.util.List<net.dv8tion.jda.core.entities.User> |
findUsers(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for User s. |
static java.util.List<net.dv8tion.jda.core.entities.VoiceChannel> |
findVoiceChannels(java.lang.String query,
net.dv8tion.jda.core.entities.Guild guild)
Queries a provided
Guild for
VoiceChannel s. |
static java.util.List<net.dv8tion.jda.core.entities.VoiceChannel> |
findVoiceChannels(java.lang.String query,
net.dv8tion.jda.core.JDA jda)
Queries a provided instance of
JDA for
VoiceChannel s. |
public static final java.util.regex.Pattern DISCORD_ID
public static final java.util.regex.Pattern FULL_USER_REF
public static final java.util.regex.Pattern USER_MENTION
public static final java.util.regex.Pattern CHANNEL_MENTION
public static final java.util.regex.Pattern ROLE_MENTION
public static final java.util.regex.Pattern EMOTE_MENTION
public static java.util.List<net.dv8tion.jda.core.entities.User> findUsers(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for User
s.
If a ShardManager
is 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:
query
- The String query to search byjda
- The instance of JDA to search fromList
of Users found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.User> findShardUsers(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for User
s.
This only queries the instance of JDA, regardless of whether or not a
ShardManager
is available.
The following special cases are applied in order of listing before the standard search is done:
query
- The String query to search byjda
- The instance of JDA to search fromList
of Users found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.User> findBannedUsers(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for a banned User
.
The following special cases are applied in order of listing before the standard search is done:
WARNING
Unlike the other finder methods, this one has two very unique features that set it apart from the rest:
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.null
if and only if an Exception
is
thrown while initially getting banned Users via Guild#getBans()
.query
- The String query to search byguild
- The Guild to search for banned Users fromList
of Users found by the query from the provided JDA instance,
or null
if an Exception
is thrown while initially getting banned Users.Guild#getBans()
public static java.util.List<net.dv8tion.jda.core.entities.Member> findMembers(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for Member
s.
The following special cases are applied in order of listing before the standard search is done:
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 in Member#getEffectiveName()
.
query
- The String query to search byguild
- The Guild to search fromList
of Members found by the query from the provided Guild.public static java.util.List<net.dv8tion.jda.core.entities.TextChannel> findTextChannels(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
TextChannel
s.
If a ShardManager
is available this will query across that
instead of the JDA instance.
The following special case is applied before the standard search is done:
query
- The String query to search byjda
- The instance of JDA to search fromList
of TextChannels found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.TextChannel> findShardTextChannels(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
TextChannel
s.
This only queries the instance of JDA, regardless of whether or not a
ShardManager
is available.
The following special case is applied before the standard search is done:
query
- The String query to search byjda
- The instance of JDA to search fromList
of TextChannels found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.TextChannel> findTextChannels(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for
TextChannel
s.
The following special case is applied before the standard search is done:
query
- The String query to search byguild
- The Guild to search fromList
of TextChannels found by the query from the provided Guild.public static java.util.List<net.dv8tion.jda.core.entities.VoiceChannel> findVoiceChannels(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
VoiceChannel
s.
If a ShardManager
is available this will query across that
instead of the JDA instance.
The standard search does not follow any special cases.
query
- The String query to search byjda
- The instance of JDA to search fromList
of VoiceChannels found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.VoiceChannel> findShardVoiceChannels(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
VoiceChannel
s.
This only queries the instance of JDA, regardless of whether or not a
ShardManager
is available.
The standard search does not follow any special cases.
query
- The String query to search byjda
- The instance of JDA to search fromList
of VoiceChannels found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.VoiceChannel> findVoiceChannels(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for
VoiceChannel
s.
The standard search does not follow any special cases.
query
- The String query to search byguild
- The Guild to search fromList
of VoiceChannels found by the query from the provided Guild.public static java.util.List<net.dv8tion.jda.core.entities.Category> findCategories(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
Categories
.
If a ShardManager
is available this will query across that
instead of the JDA instance.
The standard search does not follow any special cases.
query
- The String query to search byjda
- The instance of JDA to search fromList
of Categories found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.Category> findShardCategories(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
Categories
.
This only queries the instance of JDA, regardless of whether or not a
ShardManager
is available.
The standard search does not follow any special cases.
query
- The String query to search byjda
- The instance of JDA to search fromList
of Categories found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.Category> findCategories(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for
Categories
.
The standard search does not follow any special cases.
query
- The String query to search byguild
- The Guild to search fromList
of Categories found by the query from the provided Guild.public static java.util.List<net.dv8tion.jda.core.entities.Role> findRoles(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for Role
s.
The following special case is applied before the standard search is done:
query
- The String query to search byguild
- The Guild to search fromList
of Roles found by the query from the provided Guild.public static java.util.List<net.dv8tion.jda.core.entities.Emote> findEmotes(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
Emote
s.
If a ShardManager
is available this will query across that
instead of the JDA instance.
The following special case is applied before the standard search is done:
name
of the Emote is equal to the
name found in the query.query
- The String query to search byjda
- The instance of JDA to search fromList
of Emotes found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.Emote> findShardEmotes(java.lang.String query, net.dv8tion.jda.core.JDA jda)
JDA
for
Emote
s.
This only queries the instance of JDA, regardless of whether or not a
ShardManager
is available.
The following special case is applied before the standard search is done:
name
of the Emote is equal to the
name found in the query.query
- The String query to search byjda
- The instance of JDA to search fromList
of Emotes found by the query from the provided JDA instance.public static java.util.List<net.dv8tion.jda.core.entities.Emote> findEmotes(java.lang.String query, net.dv8tion.jda.core.entities.Guild guild)
Guild
for
Emote
s.
The following special case is applied before the standard search is done:
name
of the Emote is equal to the
name found in the query.query
- The String query to search byguild
- The Guild to search fromList
of Emotes found by the query from the provided Guild.