Interface Guild
-
- All Superinterfaces:
ISnowflake
public interface Guild extends ISnowflake
Represents a DiscordGuild
. This should contain all information provided from Discord about a Guild.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Guild.Ban
Represents a Ban object.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 AFKVoiceChannel
if one is set (Guild.getAfkChannel()
).static class
Guild.VerificationLevel
Represents the Verification-Level of the Guild.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default MemberAction
addMember(java.lang.String accessToken, long userId)
Adds the user represented by the provided id to this guild.MemberAction
addMember(java.lang.String accessToken, java.lang.String userId)
Adds the user represented by the provided id to this guild.default MemberAction
addMember(java.lang.String accessToken, User user)
Adds the provided user to this guild.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 theVoiceChannel
that has been set as the channel whichMembers
will be moved to after they have been inactive in aVoiceChannel
for longer thangetAfkTimeout()
.Guild.Timeout
getAfkTimeout()
TheTimeout
set for this Guild representing the amount of time that must pass for a Member to have had no activity in aVoiceChannel
to be considered AFK.AudioManager
getAudioManager()
TheAudioManager
that represents the audio connection for this Guild.AuditLogPaginationAction
getAuditLogs()
default RestAction<Guild.Ban>
getBan(User bannedUser)
Retrieves aBan
of the providedUser
If you wish to ban or unban a user, use eitherGuildController.ban(User, int)
orGuildController.unban(User)
.default RestAction<Guild.Ban>
getBanById(long userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherGuildController.ban(String, int)
GuildController.ban(id, int)} orGuildController.unban(String)
GuildController.unban(id)}.RestAction<Guild.Ban>
getBanById(java.lang.String userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherGuildController.ban(id, int)
orGuildController.unban(id)
.RestAction<java.util.List<Guild.Ban>>
getBanList()
Retrieves an unmodifiable list of the currently bannedUsers
.default java.util.List<Category>
getCategories()
Gets allCategories
in thisGuild
.default java.util.List<Category>
getCategoriesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allCategories
in this Guild that have the same name as the one provided.default Category
getCategoryById(long id)
Gets theCategory
from this guild that matches the provided id.default Category
getCategoryById(java.lang.String id)
Gets theCategory
from this guild that matches the provided id.SnowflakeCacheView<Category>
getCategoryCache()
SortedSnowflakeCacheView
of all cachedCategories
of this Guild.default java.util.List<Channel>
getChannels()
Populated list ofchannels
for this guild.java.util.List<Channel>
getChannels(boolean includeHidden)
Populated list ofchannels
for this guild.GuildController
getController()
Returns theGuildController
for this Guild.TextChannel
getDefaultChannel()
The defaultTextChannel
for aGuild
.Guild.NotificationLevel
getDefaultNotificationLevel()
Returns the default message Notification-Level of this Guild.default Emote
getEmoteById(long id)
Gets anEmote
from this guild that has the same id as the one provided.default Emote
getEmoteById(java.lang.String id)
Gets anEmote
from this guild that has the same id as the one provided.SnowflakeCacheView<Emote>
getEmoteCache()
SnowflakeCacheView
of all cachedEmotes
of this Guild.default java.util.List<Emote>
getEmotes()
default java.util.List<Emote>
getEmotesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allEmotes
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.util.Set<java.lang.String>
getFeatures()
The Features of theGuild
.java.lang.String
getIconId()
The Discord hash-id of theGuild
icon image.java.lang.String
getIconUrl()
The URL of theGuild
icon image.RestAction<java.util.List<Invite>>
getInvites()
Retrieves allInvites
for this guild.JDA
getJDA()
Returns theJDA
instance of this GuildGuildManager
getManager()
Returns theGuildManager
for this Guild, used to modify all properties and settings of the Guild.Member
getMember(User user)
default Member
getMemberById(long userId)
Gets aMember
object via the id of the user.default Member
getMemberById(java.lang.String userId)
Gets aMember
object via the id of the user.MemberCacheView
getMemberCache()
MemberCacheView
for all cachedMembers
of this Guild.default java.util.List<Member>
getMembers()
A list of allMembers
in this Guild.default java.util.List<Member>
getMembersByEffectiveName(java.lang.String name, boolean ignoreCase)
Gets a list of allMembers
who have the same effective name as the one provided.default java.util.List<Member>
getMembersByName(java.lang.String name, boolean ignoreCase)
Gets a list of allMembers
who have the same name as the one provided.default java.util.List<Member>
getMembersByNickname(java.lang.String nickname, boolean ignoreCase)
Gets a list of allMembers
who have the same nickname as the one provided.default java.util.List<Member>
getMembersWithRoles(java.util.Collection<Role> roles)
default java.util.List<Member>
getMembersWithRoles(Role... roles)
java.lang.String
getName()
The human readable name of theGuild
.Member
getOwner()
TheMember
object for the owner of this Guild.default java.lang.String
getOwnerId()
The ID for the current owner of this guild.long
getOwnerIdLong()
The ID for the current owner of this guild.RestAction<java.lang.Integer>
getPrunableMemberCount(int days)
The method calculates the amount of Members that would be pruned ifGuildController.prune(int)
was executed.Role
getPublicRole()
MentionPaginationAction
getRecentMentions()
Retrieves the recent mentions for the currently logged in client account in this Guild.default Region
getRegion()
The VoiceRegion
that this Guild is using for audio connections.java.lang.String
getRegionRaw()
The raw voice region name that this Guild is using for audio connections.Guild.MFALevel
getRequiredMFALevel()
Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.default Role
getRoleById(long id)
Gets aRole
from this guild that has the same id as the one provided.default Role
getRoleById(java.lang.String id)
Gets aRole
from this guild that has the same id as the one provided.SnowflakeCacheView<Role>
getRoleCache()
SortedSnowflakeCacheView
of all cachedRoles
of this Guild.default java.util.List<Role>
getRoles()
default java.util.List<Role>
getRolesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allRoles
in this Guild that have the same name as the one provided.Member
getSelfMember()
Gets theMember
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
getSystemChannel()
Provides theTextChannel
that has been set as the channel which newly joinedMembers
will be announced in.default TextChannel
getTextChannelById(long id)
Gets aTextChannel
from this guild that has the same id as the one provided.default TextChannel
getTextChannelById(java.lang.String id)
Gets aTextChannel
from this guild that has the same id as the one provided.SnowflakeCacheView<TextChannel>
getTextChannelCache()
SortedSnowflakeCacheView
of all cachedTextChannels
of this Guild.default java.util.List<TextChannel>
getTextChannels()
Gets allTextChannels
in thisGuild
.default java.util.List<TextChannel>
getTextChannelsByName(java.lang.String name, boolean ignoreCase)
Gets a list of allTextChannels
in this Guild that have the same name as the one provided.RestAction<java.lang.String>
getVanityUrl()
Gets the vanity url for this Guild.Guild.VerificationLevel
getVerificationLevel()
Returns the verification-Level of this Guild.default VoiceChannel
getVoiceChannelById(long id)
Gets aVoiceChannel
from this guild that has the same id as the one provided.default VoiceChannel
getVoiceChannelById(java.lang.String id)
Gets aVoiceChannel
from this guild that has the same id as the one provided.SnowflakeCacheView<VoiceChannel>
getVoiceChannelCache()
SortedSnowflakeCacheView
of all cachedVoiceChannels
of this Guild.default java.util.List<VoiceChannel>
getVoiceChannels()
Gets allVoiceChannels
in thisGuild
.default java.util.List<VoiceChannel>
getVoiceChannelsByName(java.lang.String name, boolean ignoreCase)
Gets a list of allVoiceChannels
in this Guild that have the same name as the one provided.java.util.List<GuildVoiceState>
getVoiceStates()
RestAction<java.util.List<Webhook>>
getWebhooks()
Retrieves allWebhooks
for this Guild.boolean
isAvailable()
Returns whether or not this Guild is available.boolean
isMember(User user)
Used to determine if the providedUser
is a member of this Guild.RestAction<java.lang.Void>
leave()
Used to leave a Guild.default RestAction<ListedEmote>
retrieveEmote(Emote emote)
Retrieves a listed emote together with its respective creator.default RestAction<ListedEmote>
retrieveEmoteById(long id)
Retrieves a listed emote together with its respective creator.RestAction<ListedEmote>
retrieveEmoteById(java.lang.String id)
Retrieves a listed emote together with its respective creator.RestAction<java.util.List<ListedEmote>>
retrieveEmotes()
Retrieves a list of emotes together with their respective creators.default RestAction<java.util.EnumSet<Region>>
retrieveRegions()
Retrieves the available regions for this Guild
Shortcut forretrieveRegions(true)
This will include deprecated voice regions by default.RestAction<java.util.EnumSet<Region>>
retrieveRegions(boolean includeDeprecated)
Retrieves the available regions for this Guild-
Methods inherited from interface net.dv8tion.jda.core.entities.ISnowflake
getCreationTime, getId, getIdLong
-
-
-
-
Method Detail
-
retrieveRegions
@CheckReturnValue default RestAction<java.util.EnumSet<Region>> retrieveRegions()
Retrieves the available regions for this Guild
Shortcut forretrieveRegions(true)
This will include deprecated voice regions by default.- Returns:
RestAction
- TypeEnumSet
-
retrieveRegions
@CheckReturnValue RestAction<java.util.EnumSet<Region>> retrieveRegions(boolean includeDeprecated)
Retrieves the available regions for this Guild- Parameters:
includeDeprecated
- Whether to include deprecated regions- Returns:
RestAction
- TypeEnumSet
-
addMember
@CheckReturnValue MemberAction addMember(java.lang.String accessToken, java.lang.String userId)
Adds the user represented by the provided id to this guild.
This requires an OAuth2 Access Token with the scopeguilds.join
.- Parameters:
accessToken
- The access tokenuserId
- The user id- Returns:
MemberAction
- Throws:
java.lang.IllegalArgumentException
- If the user id or access token is blank, empty, or null, or if the provided user is already in this guildInsufficientPermissionException
- If the currently logged in account does not havePermission.CREATE_INSTANT_INVITE
- Since:
- 3.7.0
- See Also:
- Discord OAuth2 Documentation
-
addMember
@CheckReturnValue default MemberAction addMember(java.lang.String accessToken, User user)
Adds the provided user to this guild.
This requires an OAuth2 Access Token with the scopeguilds.join
.- Parameters:
accessToken
- The access tokenuser
- The user- Returns:
MemberAction
- Throws:
java.lang.IllegalArgumentException
- If the user or access token is blank, empty, or null, or if the provided user is already in this guildInsufficientPermissionException
- If the currently logged in account does not havePermission.CREATE_INSTANT_INVITE
- Since:
- 3.7.0
- See Also:
- Discord OAuth2 Documentation
-
addMember
@CheckReturnValue default MemberAction addMember(java.lang.String accessToken, long userId)
Adds the user represented by the provided id to this guild.
This requires an OAuth2 Access Token with the scopeguilds.join
.- Parameters:
accessToken
- The access tokenuserId
- The user id- Returns:
MemberAction
- Throws:
java.lang.IllegalArgumentException
- If the user id or access token is blank, empty, or null, or if the provided user is already in this guildInsufficientPermissionException
- If the currently logged in account does not havePermission.CREATE_INSTANT_INVITE
- Since:
- 3.7.0
- See Also:
- Discord OAuth2 Documentation
-
getName
java.lang.String getName()
The human readable name of theGuild
.This value can be modified using
GuildManager.setName(String)
.- Returns:
- Never-null String containing the Guild's name.
-
getIconId
java.lang.String getIconId()
The Discord hash-id of theGuild
icon image. If no icon has been set, this returnsnull
.The Guild icon can be modified using
GuildManager.setIcon(Icon)
.- Returns:
- Possibly-null String containing the Guild's icon hash-id.
-
getIconUrl
java.lang.String getIconUrl()
The URL of theGuild
icon image. If no icon has been set, this returnsnull
.The Guild icon can be modified using
GuildManager.setIcon(Icon)
.- Returns:
- Possibly-null String containing the Guild's icon URL.
-
getFeatures
java.util.Set<java.lang.String> getFeatures()
The Features of theGuild
.Possible known features:
- VIP_REGIONS - Guild has VIP voice regions
- VANITY_URL - Guild a vanity URL (custom invite link). See
getVanityUrl()
- INVITE_SPLASH - Guild has custom invite splash. See
getSplashId()
andgetSplashUrl()
- VERIFIED - Guild is "verified"
- MORE_EMOJI - Guild is able to use more than 50 emoji
- Returns:
- Never-null, unmodifiable Set containing all of the Guild's features.
-
getSplashId
java.lang.String getSplashId()
The Discord hash-id of the splash image for this Guild. A Splash image is an image displayed when viewing a Discord Guild Invite on the web or in client just before accepting or declining the invite. If no splash has been set, this returnsnull
.
Splash images are VIP/Partner Guild only.The Guild splash can be modified using
GuildManager.setSplash(Icon)
.- Returns:
- Possibly-null String containing the Guild's splash hash-id
-
getSplashUrl
java.lang.String getSplashUrl()
The URL of the splash image for this Guild. A Splash image is an image displayed when viewing a Discord Guild Invite on the web or in client just before accepting or declining the invite. If no splash has been set, this returnsnull
.
Splash images are VIP/Partner Guild only.The Guild splash can be modified using
GuildManager.setSplash(Icon)
.- Returns:
- Possibly-null String containing the Guild's splash URL.
-
getVanityUrl
@CheckReturnValue RestAction<java.lang.String> getVanityUrl()
Gets the vanity url for this Guild. The vanity url is the custom invite code of partnered / official Guilds. The returned String will be the code that can be provided todiscord.gg/{code}
to get the invite link.
You can checkgetFeatures()
to see if this Guild has a vanity urlThis action requires the
MANAGE_SERVER
permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the task
- Returns:
RestAction
- Type: String
The vanity url of this server- Throws:
InsufficientPermissionException
- If the logged in account does not have theMANAGE_SERVER
permission.java.lang.IllegalStateException
- If the guild doesn't have the VANITY_URL feature- See Also:
getFeatures()
-
getAfkChannel
VoiceChannel getAfkChannel()
Provides theVoiceChannel
that has been set as the channel whichMembers
will be moved to after they have been inactive in aVoiceChannel
for longer thangetAfkTimeout()
.
If no channel has been set as the AFK channel, this returnsnull
.This value can be modified using
GuildManager.setAfkChannel(VoiceChannel)
.- Returns:
- Possibly-null
VoiceChannel
that is the AFK Channel.
-
getSystemChannel
TextChannel getSystemChannel()
Provides theTextChannel
that has been set as the channel which newly joinedMembers
will be announced in.
If no channel has been set as the system channel, this returnsnull
.This value can be modified using
GuildManager.setSystemChannel(TextChannel)
.- Returns:
- Possibly-null
TextChannel
that is the system Channel.
-
getOwner
Member getOwner()
TheMember
object for the owner of this Guild.Ownership can be transferred using
GuildController.transferOwnership(Member)
.- Returns:
- Member object for the Guild owner.
- See Also:
getOwnerIdLong()
-
getOwnerIdLong
long getOwnerIdLong()
The ID for the current owner of this guild.
This is useful for debugging purposes or as a shortcut.- Returns:
- The ID for the current owner
- See Also:
getOwner()
-
getOwnerId
default java.lang.String getOwnerId()
The ID for the current owner of this guild.
This is useful for debugging purposes or as a shortcut.- Returns:
- The ID for the current owner
- See Also:
getOwner()
-
getAfkTimeout
Guild.Timeout getAfkTimeout()
TheTimeout
set for this Guild representing the amount of time that must pass for a Member to have had no activity in aVoiceChannel
to be considered AFK. IfgetAfkChannel()
is notnull
(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.
Default is300 seconds (5 minutes)
.This value can be modified using
GuildManager.setAfkTimeout(net.dv8tion.jda.core.entities.Guild.Timeout)
.- Returns:
- The
Timeout
set for this Guild.
-
getRegion
default Region getRegion()
The VoiceRegion
that this Guild is using for audio connections.
If the Region is not recognized, returnsUNKNOWN
but you can still use thegetRegionRaw()
to retrieve the raw name this region has.This value can be modified using
GuildManager.setRegion(net.dv8tion.jda.core.Region)
.- Returns:
- The the audio Region this Guild is using for audio connections. Can return Region.UNKNOWN.
-
getRegionRaw
java.lang.String getRegionRaw()
The raw voice region name that this Guild is using for audio connections.
This is resolved to an enum constant ofRegion
bygetRegion()
!This value can be modified using
GuildManager.setRegion(net.dv8tion.jda.core.Region)
.- Returns:
- Raw region name
-
isMember
boolean isMember(User user)
Used to determine if the providedUser
is a member of this Guild.- Parameters:
user
- The user to determine whether or not they are a member of this guild.- Returns:
- True - if this user is present in this guild.
-
getSelfMember
Member getSelfMember()
Gets theMember
object of the currently logged in account in this guild.
This is basicallyJDA.getSelfUser()
being provided togetMember(User)
.- Returns:
- The Member object of the currently logged in account.
-
getMemberById
default Member getMemberById(java.lang.String userId)
Gets aMember
object via the id of the user. The id relates toISnowflake.getId()
, and this method is similar toJDA.getUserById(String)
This is more efficient that usingJDA.getUserById(String)
andgetMember(User)
.
If no Member in this Guild has theuserId
provided, this returnsnull
.- Parameters:
userId
- The Discord id of the User for which a Member object is requested.- Returns:
- Possibly-null
Member
with the relateduserId
. - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getMemberById
default Member getMemberById(long userId)
Gets aMember
object via the id of the user. The id relates toISnowflake.getIdLong()
, and this method is similar toJDA.getUserById(long)
This is more efficient that usingJDA.getUserById(long)
andgetMember(User)
.
If no Member in this Guild has theuserId
provided, this returnsnull
.- Parameters:
userId
- The Discord id of the User for which a Member object is requested.- Returns:
- Possibly-null
Member
with the relateduserId
.
-
getMembers
default java.util.List<Member> getMembers()
A list of allMembers
in this Guild.
The Members are not provided in any particular order.- Returns:
- Immutable list of all members in this Guild.
-
getMembersByName
default java.util.List<Member> getMembersByName(java.lang.String name, boolean ignoreCase)
Gets a list of allMembers
who have the same name as the one provided.
This compares againstMember.getUser()
.getName()
If there are noMembers
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returned Members.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Members with the same name as the name provided.
-
getMembersByNickname
default java.util.List<Member> getMembersByNickname(java.lang.String nickname, boolean ignoreCase)
Gets a list of allMembers
who have the same nickname as the one provided.
This compares againstMember.getNickname()
. If a Member does not have a nickname, the comparison results as false.
If there are noMembers
with the provided name, then this returns an empty list.- Parameters:
nickname
- The nickname used to filter the returned Members.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Members with the same nickname as the nickname provided.
-
getMembersByEffectiveName
default java.util.List<Member> getMembersByEffectiveName(java.lang.String name, boolean ignoreCase)
Gets a list of allMembers
who have the same effective name as the one provided.
This compares againstMember.getEffectiveName()
}.
If there are noMembers
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returned Members.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Members with the same effective name as the name provided.
-
getMembersWithRoles
default java.util.List<Member> getMembersWithRoles(java.util.Collection<Role> roles)
-
getMemberCache
MemberCacheView getMemberCache()
MemberCacheView
for all cachedMembers
of this Guild.- Returns:
MemberCacheView
-
getCategoryById
default Category getCategoryById(java.lang.String id)
Gets theCategory
from this guild that matches the provided id. This method is similar toJDA.getCategoryById(String)
, but it only checks in this specific Guild.
If there is no matchingCategory
this returnsnull
.- Parameters:
id
- The snowflake ID of the wanted Category- Returns:
- Possibly-null
Category
for the provided ID. - Throws:
java.lang.IllegalArgumentException
- If the provided ID is not a validlong
-
getCategoryById
default Category getCategoryById(long id)
Gets theCategory
from this guild that matches the provided id. This method is similar toJDA.getCategoryById(String)
, but it only checks in this specific Guild.
If there is no matchingCategory
this returnsnull
.- Parameters:
id
- The snowflake ID of the wanted Category- Returns:
- Possibly-null
Category
for the provided ID.
-
getCategories
default java.util.List<Category> getCategories()
Gets allCategories
in thisGuild
.
The returned categories will be sorted according to their position.- Returns:
- An immutable list of all
Categories
in this Guild.
-
getCategoriesByName
default java.util.List<Category> getCategoriesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allCategories
in this Guild that have the same name as the one provided.
If there are no matching categories this will return an empty list.- Parameters:
name
- The name to checkignoreCase
- Whether to ignore case on name checking- Returns:
- Immutable list of all categories matching the provided name
- Throws:
java.lang.IllegalArgumentException
- If the provided name isnull
-
getCategoryCache
SnowflakeCacheView<Category> getCategoryCache()
SortedSnowflakeCacheView
of all cachedCategories
of this Guild.
Categories are sorted according to their position.- Returns:
- Sorted
SnowflakeCacheView
-
getTextChannelById
default TextChannel getTextChannelById(java.lang.String id)
Gets aTextChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getTextChannelById(String)
, but it only checks this specific Guild for a TextChannel.
If there is noTextChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theTextChannel
.- Returns:
- Possibly-null
TextChannel
with matching id. - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getTextChannelById
default TextChannel getTextChannelById(long id)
Gets aTextChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getTextChannelById(long)
, but it only checks this specific Guild for a TextChannel.
If there is noTextChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theTextChannel
.- Returns:
- Possibly-null
TextChannel
with matching id.
-
getTextChannels
default java.util.List<TextChannel> getTextChannels()
Gets allTextChannels
in thisGuild
.
The channels returned will be sorted according to their position.- Returns:
- An immutable List of all
TextChannels
in this Guild.
-
getTextChannelsByName
default java.util.List<TextChannel> getTextChannelsByName(java.lang.String name, boolean ignoreCase)
Gets a list of allTextChannels
in this Guild that have the same name as the one provided.
If there are noTextChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedTextChannels
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all TextChannels names that match the provided name.
-
getTextChannelCache
SnowflakeCacheView<TextChannel> getTextChannelCache()
SortedSnowflakeCacheView
of all cachedTextChannels
of this Guild.
TextChannels are sorted according to their position.- Returns:
- Sorted
SnowflakeCacheView
-
getVoiceChannelById
default VoiceChannel getVoiceChannelById(java.lang.String id)
Gets aVoiceChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getVoiceChannelById(String)
, but it only checks this specific Guild for a VoiceChannel.
If there is noVoiceChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theVoiceChannel
.- Returns:
- Possibly-null
VoiceChannel
with matching id. - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getVoiceChannelById
default VoiceChannel getVoiceChannelById(long id)
Gets aVoiceChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getVoiceChannelById(long)
, but it only checks this specific Guild for a VoiceChannel.
If there is noVoiceChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theVoiceChannel
.- Returns:
- Possibly-null
VoiceChannel
with matching id.
-
getVoiceChannels
default java.util.List<VoiceChannel> getVoiceChannels()
Gets allVoiceChannels
in thisGuild
.
The channels returned will be sorted according to their position.- Returns:
- An immutable List of
VoiceChannels
.
-
getVoiceChannelsByName
default java.util.List<VoiceChannel> getVoiceChannelsByName(java.lang.String name, boolean ignoreCase)
Gets a list of allVoiceChannels
in this Guild that have the same name as the one provided.
If there are noVoiceChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedVoiceChannels
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all VoiceChannel names that match the provided name.
-
getVoiceChannelCache
SnowflakeCacheView<VoiceChannel> getVoiceChannelCache()
SortedSnowflakeCacheView
of all cachedVoiceChannels
of this Guild.
VoiceChannels are sorted according to their position.- Returns:
- Sorted
SnowflakeCacheView
-
getChannels
default java.util.List<Channel> getChannels()
Populated list ofchannels
for this guild. This includes all types of channels, such as category/voice/text.
This includes hidden channels by default.The returned list is ordered in the same fashion as it would be by the official discord client.
- TextChannel without parent
- VoiceChannel without parent
- Categories
- TextChannel with category as parent
- VoiceChannel with category as parent
- Returns:
- Immutable list of channels for this guild
- See Also:
getChannels(boolean)
-
getChannels
java.util.List<Channel> getChannels(boolean includeHidden)
Populated list ofchannels
for this guild. This includes all types of channels, such as category/voice/text.The returned list is ordered in the same fashion as it would be by the official discord client.
- TextChannel without parent
- VoiceChannel without parent
- Categories
- TextChannel with category as parent
- VoiceChannel with category as parent
- Parameters:
includeHidden
- Whether to include channels with deniedView Channel Permission
- Returns:
- Immutable list of channels for this guild
- See Also:
getChannels()
-
getRoleById
default Role getRoleById(java.lang.String id)
-
getRoleById
default Role getRoleById(long id)
-
getRolesByName
default java.util.List<Role> getRolesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allRoles
in this Guild that have the same name as the one provided.
If there are noRoles
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedRoles
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Role names that match the provided name.
-
getRoleCache
SnowflakeCacheView<Role> getRoleCache()
SortedSnowflakeCacheView
of all cachedRoles
of this Guild.
Roles are sorted according to their position.- Returns:
- Sorted
SnowflakeCacheView
-
getEmoteById
default Emote getEmoteById(java.lang.String id)
Gets anEmote
from this guild that has the same id as the one provided.
If there is noEmote
with an id that matches the provided one, then this returnsnull
.
This will be null ifCacheFlag.EMOTE
is disabled.Unicode emojis are not included as
Emote
!- Parameters:
id
- the emote id- Returns:
- An Emote matching the specified Id.
- Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getEmoteById
default Emote getEmoteById(long id)
Gets anEmote
from this guild that has the same id as the one provided.
If there is noEmote
with an id that matches the provided one, then this returnsnull
.
This will be null ifCacheFlag.EMOTE
is disabled.Unicode emojis are not included as
Emote
!- Parameters:
id
- the emote id- Returns:
- An Emote matching the specified Id.
-
getEmotes
default java.util.List<Emote> getEmotes()
Gets all customEmotes
belonging to thisGuild
.
Emotes are not ordered in any specific way in the returned list.Unicode emojis are not included as
Emote
!- Returns:
- An immutable List of
Emotes
.
-
getEmotesByName
default java.util.List<Emote> getEmotesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allEmotes
in this Guild that have the same name as the one provided.
If there are noEmotes
with the provided name, then this returns an empty list.
This will be empty ifCacheFlag.EMOTE
is disabled.Unicode emojis are not included as
Emote
!- Parameters:
name
- The name used to filter the returnedEmotes
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Role names that match the provided name.
-
getEmoteCache
SnowflakeCacheView<Emote> getEmoteCache()
SnowflakeCacheView
of all cachedEmotes
of this Guild.
This will be empty ifCacheFlag.EMOTE
is disabled.- Returns:
SnowflakeCacheView
-
retrieveEmotes
@Nonnull @CheckReturnValue RestAction<java.util.List<ListedEmote>> retrieveEmotes()
Retrieves a list of emotes together with their respective creators.Note that
ListedEmote.getUser()
is only available if the currently logged in account hasPermission.MANAGE_EMOTES
.- Returns:
RestAction
- Type: List ofListedEmote
- Since:
- 3.8.0
-
retrieveEmoteById
@Nonnull @CheckReturnValue RestAction<ListedEmote> retrieveEmoteById(@Nonnull java.lang.String id)
Retrieves a listed emote together with its respective creator.
This does not include unicode emoji.Note that
ListedEmote.getUser()
is only available if the currently logged in account hasPermission.MANAGE_EMOTES
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided id does not correspond to an emote in this guild
- Parameters:
id
- The emote id- Returns:
RestAction
- Type:ListedEmote
- Throws:
java.lang.IllegalArgumentException
- If the provided id is not a valid snowflake- Since:
- 3.8.0
-
retrieveEmoteById
@Nonnull @CheckReturnValue default RestAction<ListedEmote> retrieveEmoteById(long id)
Retrieves a listed emote together with its respective creator.Note that
ListedEmote.getUser()
is only available if the currently logged in account hasPermission.MANAGE_EMOTES
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided id does not correspond to an emote in this guild
- Parameters:
id
- The emote id- Returns:
RestAction
- Type:ListedEmote
- Since:
- 3.8.0
-
retrieveEmote
@Nonnull @CheckReturnValue default RestAction<ListedEmote> retrieveEmote(@Nonnull Emote emote)
Retrieves a listed emote together with its respective creator.Note that
ListedEmote.getUser()
is only available if the currently logged in account hasPermission.MANAGE_EMOTES
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided emote does not correspond to an emote in this guild anymore
- Parameters:
emote
- The emote- Returns:
RestAction
- Type:ListedEmote
- Since:
- 3.8.0
-
getBanList
@Nonnull @CheckReturnValue RestAction<java.util.List<Guild.Ban>> getBanList()
Retrieves an unmodifiable list of the currently bannedUsers
.
If you wish to ban or unban a user, use eitherGuildController.ban(User, int)
orGuildController.unban(User)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the task
- Returns:
RestAction
- Type: List<Ban
>
An unmodifiable list of all users currently banned from this Guild- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.
-
getBanById
@Nonnull @CheckReturnValue default RestAction<Guild.Ban> getBanById(long userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherGuildController.ban(String, int)
GuildController.ban(id, int)} orGuildController.unban(String)
GuildController.unban(id)}.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the taskUNKNOWN_BAN
Either the ban was removed before finishing the task or it did not exist in the first place
- Parameters:
userId
- the id of the banned user- Returns:
RestAction
- Type:Ban
An unmodifiable ban object for the user banned from this guild- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.
-
getBanById
@Nonnull @CheckReturnValue RestAction<Guild.Ban> getBanById(@Nonnull java.lang.String userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherGuildController.ban(id, int)
orGuildController.unban(id)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the taskUNKNOWN_BAN
Either the ban was removed before finishing the task or it did not exist in the first place
- Parameters:
userId
- the id of the banned user- Returns:
RestAction
- Type:Ban
An unmodifiable ban object for the user banned from this guild- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.
-
getBan
@Nonnull @CheckReturnValue default RestAction<Guild.Ban> getBan(@Nonnull User bannedUser)
Retrieves aBan
of the providedUser
If you wish to ban or unban a user, use eitherGuildController.ban(User, int)
orGuildController.unban(User)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the taskUNKNOWN_BAN
Either the ban was removed before finishing the task or it did not exist in the first place
- Parameters:
bannedUser
- the banned user- Returns:
RestAction
- Type:Ban
An unmodifiable ban object for the user banned from this guild- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.
-
getPrunableMemberCount
@CheckReturnValue RestAction<java.lang.Integer> getPrunableMemberCount(int days)
The method calculates the amount of Members that would be pruned ifGuildController.prune(int)
was executed. Prunability is determined by a Member being offline for at least days days.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The prune count cannot be fetched due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the task
- Parameters:
days
- Minimum number of days since a member has been offline to get affected.- Returns:
RestAction
- Type: Integer
The amount of Members that would be affected.- Throws:
InsufficientPermissionException
- If the account doesn't haveKICK_MEMBER
Permission.java.lang.IllegalArgumentException
- If the provided days are less than1
-
getPublicRole
Role getPublicRole()
The @everyoneRole
of thisGuild
.
This role is special because itsposition
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 byMember.getRoles()
.
The ID of this Role is the Guild's ID thus it is equivalent to usinggetRoleById(getIdLong())
.- Returns:
- The @everyone
Role
-
getDefaultChannel
@Nullable TextChannel getDefaultChannel()
The defaultTextChannel
for aGuild
.
This is the channel that the Discord client will default to opening when a Guild is opened for the first time when accepting an invite that is not directed at a specificTextChannel
.Note: This channel is the first channel in the guild (ordered by position) that the
getPublicRole()
has thePermission.MESSAGE_READ
in.- Returns:
- The
TextChannel
representing the default channel for this guild
-
getManager
GuildManager getManager()
Returns theGuildManager
for this Guild, used to modify all properties and settings of the Guild.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The Manager of this Guild
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_SERVER
-
getController
GuildController getController()
Returns theGuildController
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 theGuildController
class for more info.- Returns:
- The controller for this Guild.
-
getRecentMentions
@CheckReturnValue MentionPaginationAction getRecentMentions()
Retrieves the recent mentions for the currently logged in client account in this Guild.The returned
MentionPaginationAction
allows to filter by whether the messages mention everyone or a role.- Returns:
MentionPaginationAction
- Throws:
AccountTypeException
- If the currently logged in account is not fromAccountType.CLIENT
- See Also:
JDA.asClient()
,JDAClient.getRecentMentions(Guild)
-
getAuditLogs
@CheckReturnValue AuditLogPaginationAction getAuditLogs()
APaginationAction
implementation that allows toiterate
over allAuditLogEntries
of this Guild.
This iterates from the most recent action to the first logged one. (Limit 90 days into history by discord api)Examples
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 } publicList<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 }
- Returns:
AuditLogPaginationAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have the permissionVIEW_AUDIT_LOGS
-
leave
@CheckReturnValue RestAction<java.lang.Void> leave()
Used to leave a Guild. If the currently logged in account is the owner of this guild (getOwner()
) then ownership of the Guild needs to be transferred to a differentMember
before leaving usingGuildController.transferOwnership(Member)
.- Returns:
RestAction
- Type:Void
- Throws:
java.lang.IllegalStateException
- Thrown if the currently logged in account is the Owner of this Guild.
-
delete
@CheckReturnValue RestAction<java.lang.Void> delete()
Used to completely delete a Guild. This can only be done if the currently logged in account is the owner of the Guild.
If the account has MFA enabled, usedelete(String)
instead to provide the MFA code.- Returns:
RestAction
- Type:Void
- Throws:
PermissionException
- 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()
).
-
delete
@CheckReturnValue RestAction<java.lang.Void> delete(java.lang.String mfaCode)
Used to completely delete a guild. This can only be done if the currently logged in account is the owner of the Guild.
This method is specifically used for when MFA is enabled on the logged in accountSelfUser.isMfaEnabled()
. If MFA is not enabled, usedelete()
.- Parameters:
mfaCode
- The Multifactor Authentication code generated by an app like Google Authenticator.
This is not the MFA token given to you by Discord. The code is typically 6 characters long.- Returns:
RestAction
- Type:Void
- Throws:
PermissionException
- Thrown if the currently logged in account is not the owner of this Guild.java.lang.IllegalArgumentException
- If the providedmfaCode
isnull
or empty whenSelfUser.isMfaEnabled()
is true.
-
getAudioManager
AudioManager getAudioManager()
TheAudioManager
that represents the audio connection for this Guild.
If no AudioManager exists for this Guild, this will create a new one.
This operation is synchronized on all audio managers for this JDA instance, this means that calling getAudioManager() on any other guild while a thread is accessing this method may be locked.- Returns:
- The AudioManager for this Guild.
- See Also:
JDA.getAudioManagerCache()
-
getInvites
@CheckReturnValue RestAction<java.util.List<Invite>> getInvites()
Retrieves allInvites
for this guild.
RequiresMANAGE_SERVER
in this guild. Will throw aInsufficientPermissionException
otherwise.To get all invites for a
Channel
useChannel.getInvites()
- Returns:
RestAction
- Type: List<Invite
>
The list of expanded Invite objects- Throws:
InsufficientPermissionException
- if the account does not haveMANAGE_SERVER
in this Guild.- See Also:
Channel.getInvites()
-
getWebhooks
@CheckReturnValue RestAction<java.util.List<Webhook>> getWebhooks()
Retrieves allWebhooks
for this Guild.
RequiresMANAGE_WEBHOOKS
in this Guild.To get all webhooks for a specific
TextChannel
, useTextChannel.getWebhooks()
- Returns:
RestAction
- Type: List<Webhook
>
A list of all Webhooks in this Guild.- Throws:
InsufficientPermissionException
- if the account does not haveMANAGE_WEBHOOKS
in this Guild.- See Also:
TextChannel.getWebhooks()
-
getVoiceStates
java.util.List<GuildVoiceState> getVoiceStates()
A list containing theGuildVoiceState
of everyMember
in thisGuild
.
This will never return an empty list because if it were empty, that would imply that there are noMembers
in thisGuild
, which is impossible.- Returns:
- Never-empty list containing all the
GuildVoiceStates
on thisGuild
.
-
getVerificationLevel
Guild.VerificationLevel getVerificationLevel()
Returns the verification-Level of this Guild. Verification level is one of the factors that determines if a Member can send messages in a Guild.
For a short description of the different values, seeGuild.VerificationLevel
.This value can be modified using
GuildManager.setVerificationLevel(net.dv8tion.jda.core.entities.Guild.VerificationLevel)
.- Returns:
- The Verification-Level of this Guild.
-
getDefaultNotificationLevel
Guild.NotificationLevel getDefaultNotificationLevel()
Returns the default message Notification-Level of this Guild. Notification level determines when Members get notification for messages. The value returned is the default level set for any new Members that join the Guild.
For a short description of the different values, seeNotificationLevel
.This value can be modified using
GuildManager.setDefaultNotificationLevel(net.dv8tion.jda.core.entities.Guild.NotificationLevel)
.- Returns:
- The default message Notification-Level of this Guild.
-
getRequiredMFALevel
Guild.MFALevel getRequiredMFALevel()
Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.
For a short description of the different values, seeMFALevel
.This value can be modified using
GuildManager.setRequiredMFALevel(net.dv8tion.jda.core.entities.Guild.MFALevel)
.- Returns:
- The MFA-Level required by this Guild.
-
getExplicitContentLevel
Guild.ExplicitContentLevel getExplicitContentLevel()
The level of content filtering enabled in this Guild.
This decides which messages sent by which Members will be scanned for explicit content.- Returns:
ExplicitContentLevel
for this Guild
-
checkVerification
boolean checkVerification()
Checks if the current Verification-level of this guild allows JDA to send messages to it.- Returns:
- True if Verification-level allows sending of messages, false if not.
- See Also:
VerificationLevel Enum with a list of possible verification-levels and their requirements
-
isAvailable
boolean isAvailable()
Returns whether or not this Guild is available. A Guild can be unavailable, if the Discord server has problems.
If a Guild is unavailable, no actions on it can be performed (Messages, Manager,...)- Returns:
- If the Guild is available
-
-