public interface Guild extends ISnowflake
Guild.
This should contain all information provided from Discord about a Guild.| Modifier and Type | Interface and Description |
|---|---|
static class |
Guild.ExplicitContentLevel
The Explicit-Content-Filter Level of a Guild.
|
static class |
Guild.MFALevel
Represents the Multifactor Authentication level required by the Guild.
|
static class |
Guild.NotificationLevel
Represents the Notification-level of the Guild.
|
static class |
Guild.Timeout
Represents the idle time allowed until a user is moved to the
AFK
VoiceChannel if one is set
(Guild.getAfkChannel()). |
static class |
Guild.VerificationLevel
Represents the Verification-Level of the Guild.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkVerification()
Checks if the current Verification-level of this guild allows JDA to send messages to it.
|
RestAction<java.lang.Void> |
delete()
Used to completely delete a Guild.
|
RestAction<java.lang.Void> |
delete(java.lang.String mfaCode)
Used to completely delete a guild.
|
VoiceChannel |
getAfkChannel()
Provides the
VoiceChannel that has been set as the channel
which Members will be moved to after they have been inactive in a
VoiceChannel for longer than getAfkTimeout(). |
Guild.Timeout |
getAfkTimeout()
The
Timeout set for this Guild representing the amount of time
that must pass for a Member to have had no activity in a VoiceChannel
to be considered AFK. |
AudioManager |
getAudioManager()
Returns the
AudioManager that represents the
audio connection for this Guild. |
AuditLogPaginationAction |
getAuditLogs()
|
RestAction<java.util.List<User>> |
getBans()
Gets an unmodifiable list of the currently banned
Users. |
GuildController |
getController()
Returns the
GuildController for this Guild. |
Guild.NotificationLevel |
getDefaultNotificationLevel()
Returns the default message Notification-Level of this Guild.
|
Emote |
getEmoteById(long id)
Gets an
Emote from this guild that has the same id as the
one provided. |
Emote |
getEmoteById(java.lang.String id)
Gets an
Emote from this guild that has the same id as the
one provided. |
java.util.List<Emote> |
getEmotes()
|
java.util.List<Emote> |
getEmotesByName(java.lang.String name,
boolean ignoreCase)
Gets a list of all
Emotes in this Guild that have the same
name as the one provided. |
Guild.ExplicitContentLevel |
getExplicitContentLevel()
The level of content filtering enabled in this Guild.
|
java.lang.String |
getIconId()
The Discord hash-id of the
Guild icon image. |
java.lang.String |
getIconUrl()
The URL of the
Guild icon image. |
RestAction<java.util.List<Invite>> |
getInvites()
Retrieves all
Invites for this guild. |
JDA |
getJDA()
Returns the
JDA instance of this Guild |
GuildManager |
getManager()
Returns the
GuildManager for this Guild, used to modify
all properties and settings of the Guild. |
GuildManagerUpdatable |
getManagerUpdatable()
Returns the
Updatable GuildManager for this Guild, used to modify
all properties and settings of the Guild. |
Member |
getMember(User user)
|
Member |
getMemberById(long userId)
Gets a
Member object via the id of the user. |
Member |
getMemberById(java.lang.String userId)
Gets a
Member object via the id of the user. |
java.util.List<Member> |
getMembers()
A list of all
Members in this Guild. |
java.util.List<Member> |
getMembersByEffectiveName(java.lang.String name,
boolean ignoreCase)
Gets a list of all
Members who have the same effective name as the one provided. |
java.util.List<Member> |
getMembersByName(java.lang.String name,
boolean ignoreCase)
Gets a list of all
Members who have the same name as the one provided. |
java.util.List<Member> |
getMembersByNickname(java.lang.String nickname,
boolean ignoreCase)
Gets a list of all
Members who have the same nickname as the one provided. |
java.util.List<Member> |
getMembersWithRoles(java.util.Collection<Role> roles)
|
java.util.List<Member> |
getMembersWithRoles(Role... roles)
|
java.lang.String |
getName()
The human readable name of the
Guild. |
Member |
getOwner()
|
RestAction<java.lang.Integer> |
getPrunableMemberCount(int days)
The method calculates the amount of Members that would be pruned if
GuildController.prune(int) was executed. |
TextChannel |
getPublicChannel()
The default
TextChannel for a Guild. |
Role |
getPublicRole()
|
MentionPaginationAction |
getRecentMentions()
Retrieves the recent mentions for the currently logged in
client account in this Guild.
|
Region |
getRegion()
|
Guild.MFALevel |
getRequiredMFALevel()
Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.
|
Role |
getRoleById(long id)
Gets a
Role from this guild that has the same id as the
one provided. |
Role |
getRoleById(java.lang.String id)
Gets a
Role from this guild that has the same id as the
one provided. |
java.util.List<Role> |
getRoles()
|
java.util.List<Role> |
getRolesByName(java.lang.String name,
boolean ignoreCase)
Gets a list of all
Roles in this Guild that have the same
name as the one provided. |
Member |
getSelfMember()
Gets the
Member object of the currently logged in account in this guild. |
java.lang.String |
getSplashId()
The Discord hash-id of the splash image for this Guild.
|
java.lang.String |
getSplashUrl()
The URL of the splash image for this Guild.
|
TextChannel |
getTextChannelById(long id)
Gets a
TextChannel from this guild that has the same id as the
one provided. |
TextChannel |
getTextChannelById(java.lang.String id)
Gets a
TextChannel from this guild that has the same id as the
one provided. |
java.util.List<TextChannel> |
getTextChannels()
Gets all
TextChannels in this Guild. |
java.util.List<TextChannel> |
getTextChannelsByName(java.lang.String name,
boolean ignoreCase)
Gets a list of all
TextChannels in this Guild that have the same
name as the one provided. |
Guild.VerificationLevel |
getVerificationLevel()
Returns the verification-Level of this Guild.
|
VoiceChannel |
getVoiceChannelById(long id)
Gets a
VoiceChannel from this guild that has the same id as the
one provided. |
VoiceChannel |
getVoiceChannelById(java.lang.String id)
Gets a
VoiceChannel from this guild that has the same id as the
one provided. |
java.util.List<VoiceChannel> |
getVoiceChannels()
Gets all
VoiceChannels in this Guild. |
java.util.List<VoiceChannel> |
getVoiceChannelsByName(java.lang.String name,
boolean ignoreCase)
Gets a list of all
VoiceChannels in this Guild that have the same
name as the one provided. |
java.util.List<GuildVoiceState> |
getVoiceStates()
|
RestAction<java.util.List<Webhook>> |
getWebhooks()
Retrieves all
Webhooks for this Guild. |
boolean |
isAvailable()
Returns whether or not this Guild is available.
|
boolean |
isMember(User user)
Used to determine if the provided
User is a member of this Guild. |
RestAction<java.lang.Void> |
leave()
Used to leave a Guild.
|
getCreationTime, getId, getIdLongjava.lang.String getName()
Guild.
This value can be modified using GuildManager.setName(String)
or GuildManagerUpdatable.getNameField().
java.lang.String getIconId()
Guild icon image.
If no icon has been set, this returns null.
The Guild icon can be modified using GuildManager.setIcon(Icon)
or GuildManagerUpdatable.getIconField().
java.lang.String getIconUrl()
Guild icon image.
If no icon has been set, this returns null.
The Guild icon can be modified using GuildManager.setIcon(Icon)
or GuildManagerUpdatable.getIconField().
java.lang.String getSplashId()
null.
The Guild splash can be modified using GuildManager.setSplash(Icon)
or GuildManagerUpdatable.getSplashField().
java.lang.String getSplashUrl()
null.
The Guild splash can be modified using GuildManager.setSplash(Icon)
or GuildManagerUpdatable.getSplashField().
VoiceChannel getAfkChannel()
VoiceChannel that has been set as the channel
which Members will be moved to after they have been inactive in a
VoiceChannel for longer than getAfkTimeout().
null.
This value can be modified using GuildManager.setAfkChannel(VoiceChannel)
or GuildManagerUpdatable.getAfkChannelField().
VoiceChannel that is the AFK Channel.Member getOwner()
Member object of the owner of this Guild.
Ownership can be transferred using GuildController.transferOwnership(Member).
Guild.Timeout getAfkTimeout()
Timeout set for this Guild representing the amount of time
that must pass for a Member to have had no activity in a VoiceChannel
to be considered AFK. If getAfkChannel() is not null (thus an AFK channel has been set) then Member
will be automatically moved to the AFK channel after they have been inactive for longer than the returned Timeout.
300 seconds (5 minutes).
This value can be modified using GuildManager.setAfkTimeout(net.dv8tion.jda.core.entities.Guild.Timeout)
or GuildManagerUpdatable.getAfkTimeoutField().
Timeout set for this Guild.Region getRegion()
Region that this Guild is
using for audio connections.
Region is not recognized, returns UNKNOWN.
This value can be modified using GuildManager.setRegion(net.dv8tion.jda.core.Region)
or GuildManagerUpdatable.getRegionField().
boolean isMember(User user)
User is a member of this Guild.user - The user to determine whether or not they are a member of this guild.Member getSelfMember()
Member object of the currently logged in account in this guild.
JDA.getSelfUser() being provided to getMember(User).Member getMemberById(java.lang.String userId)
Member object via the id of the user. The id relates to
ISnowflake.getId(), and this method is similar to JDA.getUserById(String)
JDA.getUserById(String) and getMember(User).
userId provided, this returns null.userId - The Discord id of the User for which a Member object is requested.Member with the related userId.java.lang.NumberFormatException - If the provided id cannot be parsed by Long.parseLong(String)Member getMemberById(long userId)
Member object via the id of the user. The id relates to
ISnowflake.getIdLong(), and this method is similar to JDA.getUserById(long)
JDA.getUserById(long) and getMember(User).
userId provided, this returns null.userId - The Discord id of the User for which a Member object is requested.Member with the related userId.java.util.List<Member> getMembers()
Members in this Guild.
java.util.List<Member> getMembersByName(java.lang.String name, boolean ignoreCase)
Members who have the same name as the one provided.
Member.getUser().getName()
Members with the provided name, then this returns an empty list.name - The name used to filter the returned Members.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.java.util.List<Member> getMembersByNickname(java.lang.String nickname, boolean ignoreCase)
Members who have the same nickname as the one provided.
Member.getNickname(). If a Member does not have a nickname, the comparison results as false.
Members with the provided name, then this returns an empty list.nickname - The nickname used to filter the returned Members.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.java.util.List<Member> getMembersByEffectiveName(java.lang.String name, boolean ignoreCase)
Members who have the same effective name as the one provided.
Member.getEffectiveName()}.
Members with the provided name, then this returns an empty list.name - The name used to filter the returned Members.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.TextChannel getTextChannelById(java.lang.String id)
TextChannel from this guild that has the same id as the
one provided. This method is similar to JDA.getTextChannelById(String), but it only
checks this specific Guild for a TextChannel.
TextChannel with an id that matches the provided
one, then this returns null.id - The id of the TextChannel.TextChannel with matching id.java.lang.NumberFormatException - If the provided id cannot be parsed by Long.parseLong(String)TextChannel getTextChannelById(long id)
TextChannel from this guild that has the same id as the
one provided. This method is similar to JDA.getTextChannelById(long), but it only
checks this specific Guild for a TextChannel.
TextChannel with an id that matches the provided
one, then this returns null.id - The id of the TextChannel.TextChannel with matching id.java.util.List<TextChannel> getTextChannels()
TextChannels in this Guild.
TextChannels in this Guild.java.util.List<TextChannel> getTextChannelsByName(java.lang.String name, boolean ignoreCase)
TextChannels in this Guild that have the same
name as the one provided.
TextChannels with the provided name, then this returns an empty list.name - The name used to filter the returned TextChannels.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.VoiceChannel getVoiceChannelById(java.lang.String id)
VoiceChannel from this guild that has the same id as the
one provided. This method is similar to JDA.getVoiceChannelById(String), but it only
checks this specific Guild for a VoiceChannel.
VoiceChannel with an id that matches the provided
one, then this returns null.id - The id of the VoiceChannel.VoiceChannel with matching id.java.lang.NumberFormatException - If the provided id cannot be parsed by Long.parseLong(String)VoiceChannel getVoiceChannelById(long id)
VoiceChannel from this guild that has the same id as the
one provided. This method is similar to JDA.getVoiceChannelById(long), but it only
checks this specific Guild for a VoiceChannel.
VoiceChannel with an id that matches the provided
one, then this returns null.id - The id of the VoiceChannel.VoiceChannel with matching id.java.util.List<VoiceChannel> getVoiceChannels()
VoiceChannels in this Guild.
VoiceChannels.java.util.List<VoiceChannel> getVoiceChannelsByName(java.lang.String name, boolean ignoreCase)
VoiceChannels in this Guild that have the same
name as the one provided.
VoiceChannels with the provided name, then this returns an empty list.name - The name used to filter the returned VoiceChannels.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.Role getRoleById(java.lang.String id)
Role getRoleById(long id)
java.util.List<Role> getRolesByName(java.lang.String name, boolean ignoreCase)
Roles in this Guild that have the same
name as the one provided.
Roles with the provided name, then this returns an empty list.name - The name used to filter the returned Roles.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.Emote getEmoteById(java.lang.String id)
Emote from this guild that has the same id as the
one provided.
Emote with an id that matches the provided
one, then this returns null.
Unicode emojis are not included as Emote!
id - the emote idjava.lang.NumberFormatException - If the provided id cannot be parsed by Long.parseLong(String)Emote getEmoteById(long id)
Emote from this guild that has the same id as the
one provided.
Emote with an id that matches the provided
one, then this returns null.
Unicode emojis are not included as Emote!
id - the emote idjava.util.List<Emote> getEmotes()
Emotes belonging to this Guild.
Unicode emojis are not included as Emote!
Emotes.java.util.List<Emote> getEmotesByName(java.lang.String name, boolean ignoreCase)
Emotes in this Guild that have the same
name as the one provided.
Emotes with the provided name, then this returns an empty list.
Unicode emojis are not included as Emote!
name - The name used to filter the returned Emotes.ignoreCase - Determines if the comparison ignores case when comparing. True - case insensitive.@CheckReturnValue RestAction<java.util.List<User>> getBans()
Users.
GuildController.ban(User, int) or
GuildController.ban(User).
Possible ErrorResponses caused by
the returned RestAction include the following:
MISSING_PERMISSIONS
MISSING_ACCESS
RestAction - Type: List<User>
InsufficientPermissionException - If the logged in account does not have the Permission.BAN_MEMBERS permission.GuildUnavailableException - If the guild is temporarily not available@CheckReturnValue RestAction<java.lang.Integer> getPrunableMemberCount(int days)
GuildController.prune(int) was executed.
Prunability is determined by a Member being offline for at least days days.
Possible ErrorResponses caused by
the returned RestAction include the following:
MISSING_PERMISSIONS
MISSING_ACCESS
days - Minimum number of days since a member has been offline to get affected.RestAction - Type: Integer
InsufficientPermissionException - If the account doesn't have KICK_MEMBER Permission.GuildUnavailableException - If the guild is temporarily not availablejava.lang.IllegalArgumentException - If the provided days are less than 1Role getPublicRole()
Role of this Guild.
Role.getPosition() is calculated as
-1. All other role positions are 0 or greater. This implies that the public role is always below
any custom roles created in this Guild. Additionally, all members of this guild are implied to have this role so
it is not included in the list returned by Member.getRoles().RoleTextChannel getPublicChannel()
TextChannel for a Guild.
Public Role always has the ability to
Permission.MESSAGE_READ this channel.TextChannel representing the public channel for this guild.GuildManager getManager()
GuildManager for this Guild, used to modify
all properties and settings of the Guild.
getManagerUpdatable().GuildUnavailableException - if the guild is temporarily unavailable (isAvailable())GuildManagerUpdatable getManagerUpdatable()
Updatable GuildManager for this Guild, used to modify
all properties and settings of the Guild.
GuildUnavailableException - if the guild is temporarily unavailable (isAvailable())GuildController getController()
GuildController for this Guild. The controller
is used to perform all admin style functions in the Guild. A few include: kicking, banning, changing member roles,
changing role and channel positions, and more. Checkout the GuildController
class for more info.@CheckReturnValue MentionPaginationAction getRecentMentions()
The returned MentionPaginationAction
allows to filter by whether the messages mention everyone or a role.
MentionPaginationActionAccountTypeException - If the currently logged in account is not from AccountType.CLIENTGuildUnavailableException - If this Guild is not currently availableJDA.asClient(),
JDAClient.getRecentMentions(Guild)@CheckReturnValue AuditLogPaginationAction getAuditLogs()
PaginationAction implementation
that allows to iterate over all AuditLogEntries of
this Guild.
public boolean isLogged(Guild guild, ActionType type, long targetId)
{
for (AuditLogEntry entry : guild.getAuditLogs().cache(false))
{
if (entry.getType() == type && entry.getTargetIdLong() == targetId)
return true; // The action is logged
}
return false; // nothing found in audit logs
}
public List<AuditLogEntry> getActionsBy(Guild guild, User user)
{
return guild.getAuditLogs().cache(false).stream()
.filter(it -> it.getUser().equals(user))
.collect(Collectors.toList()); // collects actions done by user
}
AuditLogPaginationActionInsufficientPermissionException - If the currently logged in account
does not have the permission VIEW_AUDIT_LOGS@CheckReturnValue RestAction<java.lang.Void> leave()
getOwner())
then ownership of the Guild needs to be transferred to a different Member
before leaving using GuildController.transferOwnership(Member).RestAction - Type: Voidjava.lang.IllegalStateException - Thrown if the currently logged in account is the Owner of this Guild.@CheckReturnValue RestAction<java.lang.Void> delete()
delete(String) instead to provide the MFA code.RestAction - Type: VoidPermissionException - Thrown if the currently logged in account is not the owner of this Guild.java.lang.IllegalStateException - If the currently logged in account has MFA enabled. (SelfUser.isMfaEnabled()).@CheckReturnValue RestAction<java.lang.Void> delete(java.lang.String mfaCode)
SelfUser.isMfaEnabled().
If MFA is not enabled, use delete().mfaCode - The Multifactor Authentication code generated by an app like
Google Authenticator.
RestAction - Type: VoidPermissionException - Thrown if the currently logged in account is not the owner of this Guild.java.lang.IllegalArgumentException - If the provided mfaCode is null or empty when SelfUser.isMfaEnabled() is true.AudioManager getAudioManager()
AudioManager that represents the
audio connection for this Guild.@CheckReturnValue RestAction<java.util.List<Invite>> getInvites()
Invites for this guild.
MANAGE_SERVER in this guild.
Will throw a InsufficientPermissionException otherwise.
To get all invites for a Channel
use Channel.getInvites()
RestAction - Type: List<Invite>
InsufficientPermissionException - if the account does not have MANAGE_SERVER in this Guild.Channel.getInvites()@CheckReturnValue RestAction<java.util.List<Webhook>> getWebhooks()
Webhooks for this Guild.
MANAGE_WEBHOOKS in this Guild.
To get all webhooks for a specific TextChannel, use
TextChannel.getWebhooks()
RestAction - Type: List<Webhook>
InsufficientPermissionException - if the account does not have MANAGE_WEBHOOKS in this Guild.TextChannel.getWebhooks()java.util.List<GuildVoiceState> getVoiceStates()
GuildVoiceState of every Member
in this Guild.
Members in this Guild, which is
impossible.GuildVoiceStates on this Guild.Guild.VerificationLevel getVerificationLevel()
Guild.VerificationLevel.
This value can be modified using GuildManager.setVerificationLevel(net.dv8tion.jda.core.entities.Guild.VerificationLevel)
or GuildManagerUpdatable.getVerificationLevelField()
Guild.NotificationLevel getDefaultNotificationLevel()
NotificationLevel.
This value can be modified using GuildManager.setDefaultNotificationLevel(net.dv8tion.jda.core.entities.Guild.NotificationLevel)
or GuildManagerUpdatable.getDefaultNotificationLevelField()
Guild.MFALevel getRequiredMFALevel()
MFALevel.
This value can be modified using GuildManager.setRequiredMFALevel(net.dv8tion.jda.core.entities.Guild.MFALevel)
or GuildManagerUpdatable.getRequiredMFALevelField()
Guild.ExplicitContentLevel getExplicitContentLevel()
ExplicitContentLevel for this Guildboolean checkVerification()
VerificationLevel Enum with a list of possible verification-levels and their requirementsboolean isAvailable()