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.BoostTier
The boost tier for this guild.static class
Guild.ExplicitContentLevel
The Explicit-Content-Filter Level of a Guild.static class
Guild.MetaData
Meta-Data for a Guildstatic 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.
-
Field Summary
Fields Modifier and Type Field Description static String
BANNER_URL
Template forgetBannerUrl()
.static String
ICON_URL
Template forgetIconUrl()
.static String
SPLASH_URL
Template forgetSplashUrl()
.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default MemberAction
addMember(String accessToken, long userId)
Adds the user represented by the provided id to this guild.MemberAction
addMember(String accessToken, String userId)
Adds the user represented by the provided id to this guild.default MemberAction
addMember(String accessToken, User user)
Adds the provided user to this guild.default AuditableRestAction<Void>
addRoleToMember(long userId, Role role)
Atomically assigns the providedRole
to the specified member by their user id.default AuditableRestAction<Void>
addRoleToMember(String userId, Role role)
Atomically assigns the providedRole
to the specified member by their user id.AuditableRestAction<Void>
addRoleToMember(Member member, Role role)
default AuditableRestAction<Void>
ban(String userId, int delDays)
Bans the user specified by the userId and deletes messages sent by the user based on the amount of delDays.AuditableRestAction<Void>
ban(String userId, int delDays, String reason)
Bans the user specified by the userId and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
ban(Member member, int delDays)
Bans theMember
and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
ban(Member member, int delDays, String reason)
Bans theMember
and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
ban(User user, int delDays)
Bans theMember
and deletes messages sent by the user based on the amount of delDays.AuditableRestAction<Void>
ban(User user, int delDays, String reason)
Bans theUser
and deletes messages sent by the user based on the amount of delDays.boolean
checkVerification()
Deprecated.Bots don't need to check this and client accounts are not supportedChannelAction<Category>
createCategory(String name)
Creates a newCategory
in this Guild.default <T extends GuildChannel>
ChannelAction<T>createCopyOfChannel(T channel)
Creates a copy of the specifiedGuildChannel
in thisGuild
.default RoleAction
createCopyOfRole(Role role)
AuditableRestAction<Emote>
createEmote(String name, Icon icon, Role... roles)
Creates a newEmote
in this Guild.RoleAction
createRole()
Creates a newRole
in this Guild.ChannelAction<TextChannel>
createTextChannel(String name)
Creates a newTextChannel
in this Guild.ChannelAction<VoiceChannel>
createVoiceChannel(String name)
Creates a newVoiceChannel
in this Guild.AuditableRestAction<Void>
deafen(Member member, boolean deafen)
Sets the Guild Deafened state state of theMember
based on the provided boolean.RestAction<Void>
delete()
Used to completely delete a Guild.RestAction<Void>
delete(String mfaCode)
Used to completely delete a guild.default Task<List<Member>>
findMembers(Predicate<? super Member> filter)
Retrieves and collects members of this guild into a list.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.String
getBannerId()
The guild banner id.default String
getBannerUrl()
The guild banner url.int
getBoostCount()
The amount of boosts this server currently has.List<Member>
getBoosters()
Sorted list ofMembers
that boost this guild.Guild.BoostTier
getBoostTier()
The boost tier for this guild.default List<Category>
getCategories()
Gets allCategories
in thisGuild
.default List<Category>
getCategoriesByName(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(String id)
Gets theCategory
from this guild that matches the provided id.SortedSnowflakeCacheView<Category>
getCategoryCache()
SortedSnowflakeCacheView
of all cachedCategories
of this Guild.default List<GuildChannel>
getChannels()
Populated list ofchannels
for this guild.List<GuildChannel>
getChannels(boolean includeHidden)
Populated list ofchannels
for this guild.TextChannel
getDefaultChannel()
The defaultTextChannel
for aGuild
.Guild.NotificationLevel
getDefaultNotificationLevel()
Returns the default message Notification-Level of this Guild.String
getDescription()
The description for this guild.default Emote
getEmoteById(long id)
Gets anEmote
from this guild that has the same id as the one provided.default Emote
getEmoteById(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 List<Emote>
getEmotes()
default List<Emote>
getEmotesByName(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.Set<String>
getFeatures()
The Features of theGuild
.default GuildChannel
getGuildChannelById(long id)
GetGuildChannel
for the provided ID.default GuildChannel
getGuildChannelById(String id)
GetGuildChannel
for the provided ID.default GuildChannel
getGuildChannelById(ChannelType type, long id)
GetGuildChannel
for the provided ID.default GuildChannel
getGuildChannelById(ChannelType type, String id)
GetGuildChannel
for the provided ID.String
getIconId()
The Discord hash-id of theGuild
icon image.default String
getIconUrl()
The URL of theGuild
icon image.JDA
getJDA()
Returns theJDA
instance of this GuildLocale
getLocale()
The preferred locale for this guild.GuildManager
getManager()
Returns theGuildManager
for this Guild, used to modify all properties and settings of the Guild.default int
getMaxBitrate()
The maximum bitrate that can be applied to a voice channel in this guild.default int
getMaxEmotes()
The maximum amount of emotes a guild can have based on the guilds boost tier.default long
getMaxFileSize()
Returns the maximum size for files that can be uploaded to this Guild.int
getMaxMembers()
The maximum amount of members that can join this guild.int
getMaxPresences()
The maximum amount of connected members this guild can have at a time.Member
getMember(User user)
default Member
getMemberById(long userId)
Gets aMember
object via the id of the user.default Member
getMemberById(String userId)
Gets aMember
object via the id of the user.default Member
getMemberByTag(String tag)
Searches for aMember
that has the matching Discord Tag.default Member
getMemberByTag(String username, String discriminator)
Searches for aMember
that has the matching Discord Tag.MemberCacheView
getMemberCache()
MemberCacheView
for all cachedMembers
of this Guild.int
getMemberCount()
The expected member count for this guild.default List<Member>
getMembers()
A list of allMembers
in this Guild.default List<Member>
getMembersByEffectiveName(String name, boolean ignoreCase)
Gets a list of allMembers
who have the same effective name as the one provided.default List<Member>
getMembersByName(String name, boolean ignoreCase)
Gets a list of allMembers
who have the same name as the one provided.default List<Member>
getMembersByNickname(String nickname, boolean ignoreCase)
Gets a list of allMembers
who have the same nickname as the one provided.default List<Member>
getMembersWithRoles(Collection<Role> roles)
default List<Member>
getMembersWithRoles(Role... roles)
String
getName()
The human readable name of theGuild
.Member
getOwner()
TheMember
object for the owner of this Guild.default String
getOwnerId()
The ID for the current owner of this guild.long
getOwnerIdLong()
The ID for the current owner of this guild.Role
getPublicRole()
default Region
getRegion()
The VoiceRegion
that this Guild is using for audio connections.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(String id)
Gets aRole
from this guild that has the same id as the one provided.SortedSnowflakeCacheView<Role>
getRoleCache()
SortedSnowflakeCacheView
of all cachedRoles
of this Guild.default List<Role>
getRoles()
default List<Role>
getRolesByName(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.String
getSplashId()
The Discord hash-id of the splash image for this Guild.default String
getSplashUrl()
The URL of the splash image for this Guild.default StoreChannel
getStoreChannelById(long id)
Gets aStoreChannel
from this guild that has the same id as the one provided.default StoreChannel
getStoreChannelById(String id)
Gets aStoreChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView<StoreChannel>
getStoreChannelCache()
SortedSnowflakeCacheView
of all cachedStoreChannels
of this Guild.default List<StoreChannel>
getStoreChannels()
Gets allStoreChannels
in thisGuild
.default List<StoreChannel>
getStoreChannelsByName(String name, boolean ignoreCase)
Gets a list of allStoreChannels
in this Guild that have the same name as the one provided.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(String id)
Gets aTextChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView<TextChannel>
getTextChannelCache()
SortedSnowflakeCacheView
of all cachedTextChannels
of this Guild.default List<TextChannel>
getTextChannels()
Gets allTextChannels
in thisGuild
.default List<TextChannel>
getTextChannelsByName(String name, boolean ignoreCase)
Gets a list of allTextChannels
in this Guild that have the same name as the one provided.String
getVanityCode()
The vanity url code for this Guild.default String
getVanityUrl()
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(String id)
Gets aVoiceChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView<VoiceChannel>
getVoiceChannelCache()
SortedSnowflakeCacheView
of all cachedVoiceChannels
of this Guild.default List<VoiceChannel>
getVoiceChannels()
Gets allVoiceChannels
in thisGuild
.default List<VoiceChannel>
getVoiceChannelsByName(String name, boolean ignoreCase)
Gets a list of allVoiceChannels
in this Guild that have the same name as the one provided.List<GuildVoiceState>
getVoiceStates()
boolean
isAvailable()
Deprecated.This will be removed in a future version, unavailable guilds are now removed from cache.boolean
isLoaded()
Whether this guild has loaded members.boolean
isMember(User user)
Used to determine if the providedUser
is a member of this Guild.default AuditableRestAction<Void>
kick(String userId)
AuditableRestAction<Void>
kick(String userId, String reason)
default AuditableRestAction<Void>
kick(Member member)
AuditableRestAction<Void>
kick(Member member, String reason)
default RestAction<Void>
kickVoiceMember(Member member)
Used to kick aMember
from aVoiceChannel
.RestAction<Void>
leave()
Used to leave a Guild.default Task<List<Member>>
loadMembers()
Retrieves and collects members of this guild into a list.Task<Void>
loadMembers(Consumer<Member> callback)
Retrieves all members of this guild.ChannelOrderAction
modifyCategoryPositions()
Modifies the positional order ofGuild.getCategories()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.AuditableRestAction<Void>
modifyMemberRoles(Member member, Collection<Role> roles)
AuditableRestAction<Void>
modifyMemberRoles(Member member, Collection<Role> rolesToAdd, Collection<Role> rolesToRemove)
default AuditableRestAction<Void>
modifyMemberRoles(Member member, Role... roles)
AuditableRestAction<Void>
modifyNickname(Member member, String nickname)
Changes the Member's nickname in this guild.default RoleOrderAction
modifyRolePositions()
Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.RoleOrderAction
modifyRolePositions(boolean useAscendingOrder)
Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.ChannelOrderAction
modifyTextChannelPositions()
Modifies the positional order ofGuild.getTextChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.CategoryOrderAction
modifyTextChannelPositions(Category category)
Modifies the positional order ofCategory#getTextChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedTextChannels
of thisCategory
.ChannelOrderAction
modifyVoiceChannelPositions()
Modifies the positional order ofGuild.getVoiceChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.CategoryOrderAction
modifyVoiceChannelPositions(Category category)
Modifies the positional order ofCategory#getVoiceChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedVoiceChannels
of thisCategory
.RestAction<Void>
moveVoiceMember(Member member, VoiceChannel voiceChannel)
AuditableRestAction<Void>
mute(Member member, boolean mute)
Sets the Guild Muted state state of theMember
based on the provided boolean.AuditableRestAction<Integer>
prune(int days, boolean wait, Role... roles)
This method will prune (kick) all members who were offline for at least days days.default AuditableRestAction<Integer>
prune(int days, Role... roles)
This method will prune (kick) all members who were offline for at least days days.void
pruneMemberCache()
Re-apply theMemberCachePolicy
of this session to allMembers
of this Guild.default AuditableRestAction<Void>
removeRoleFromMember(long userId, Role role)
Atomically removes the providedRole
from the specified member by their user id.default AuditableRestAction<Void>
removeRoleFromMember(String userId, Role role)
Atomically removes the providedRole
from the specified member by their user id.AuditableRestAction<Void>
removeRoleFromMember(Member member, Role role)
AuditLogPaginationAction
retrieveAuditLogs()
default RestAction<Guild.Ban>
retrieveBan(User bannedUser)
Retrieves aBan
of the providedUser
If you wish to ban or unban a user, use eitherban(User, int)
orunban(User)
.default RestAction<Guild.Ban>
retrieveBanById(long userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherban(String, int)
ban(id, int)} orunban(String)
unban(id)}.RestAction<Guild.Ban>
retrieveBanById(String userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherban(id, int)
orunban(id)
.RestAction<List<Guild.Ban>>
retrieveBanList()
Retrieves an immutable list of the currently bannedUsers
.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(String id)
Retrieves a listed emote together with its respective creator.RestAction<List<ListedEmote>>
retrieveEmotes()
Retrieves an immutable list of emotes together with their respective creators.RestAction<List<Invite>>
retrieveInvites()
Retrieves allInvites
for this guild.default RestAction<Member>
retrieveMember(User user)
Load the member for the specified user.default RestAction<Member>
retrieveMember(User user, boolean update)
Load the member for the specified user.default RestAction<Member>
retrieveMemberById(long id)
Load the member for the specified user.RestAction<Member>
retrieveMemberById(long id, boolean update)
Load the member for the specified user.default RestAction<Member>
retrieveMemberById(String id)
Load the member for the specified user.default RestAction<Member>
retrieveMemberById(String id, boolean update)
Load the member for the specified user.CompletableFuture<Void>
retrieveMembers()
Deprecated.default Task<List<Member>>
retrieveMembers(boolean includePresence, Collection<User> users)
Retrieves a list of members.default Task<List<Member>>
retrieveMembers(Collection<User> users)
Retrieves a list of members.Task<List<Member>>
retrieveMembersByIds(boolean includePresence, long... ids)
Retrieves a list of members by their user id.default Task<List<Member>>
retrieveMembersByIds(boolean includePresence, String... ids)
Retrieves a list of members by their user id.default Task<List<Member>>
retrieveMembersByIds(boolean includePresence, Collection<Long> ids)
Retrieves a list of members by their user id.default Task<List<Member>>
retrieveMembersByIds(long... ids)
Retrieves a list of members by their user id.default Task<List<Member>>
retrieveMembersByIds(String... ids)
Retrieves a list of members by their user id.default Task<List<Member>>
retrieveMembersByIds(Collection<Long> ids)
Retrieves a list of members by their user id.Task<List<Member>>
retrieveMembersByPrefix(String prefix, int limit)
Queries a list of members using a radix tree based on the provided name prefix.RestAction<Guild.MetaData>
retrieveMetaData()
LoadsGuild.MetaData
for this guild instance.default RestAction<Member>
retrieveOwner()
Shortcut forguild.retrieveMemberById(guild.getOwnerIdLong())
.default RestAction<Member>
retrieveOwner(boolean update)
Shortcut forguild.retrieveMemberById(guild.getOwnerIdLong())
.RestAction<Integer>
retrievePrunableMemberCount(int days)
The method calculates the amount of Members that would be pruned ifprune(int, Role...)
was executed.default RestAction<EnumSet<Region>>
retrieveRegions()
Retrieves the available regions for this Guild
Shortcut forretrieveRegions(true)
This will include deprecated voice regions by default.RestAction<EnumSet<Region>>
retrieveRegions(boolean includeDeprecated)
Retrieves the available regions for this GuildRestAction<String>
retrieveVanityUrl()
Deprecated.RestAction<List<Webhook>>
retrieveWebhooks()
Retrieves allWebhooks
for this Guild.AuditableRestAction<Void>
transferOwnership(Member newOwner)
Transfers the Guild ownership to the specifiedMember
Only available if the currently logged in account is the owner of this GuildAuditableRestAction<Void>
unban(String userId)
Unbans the a user specified by the userId from this Guild.default AuditableRestAction<Void>
unban(User user)
Unbans the specifiedUser
from this Guild.boolean
unloadMember(long userId)
Attempts to remove the user with the provided id from the member cache.-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Field Detail
-
ICON_URL
static final String ICON_URL
Template forgetIconUrl()
.- See Also:
- Constant Field Values
-
SPLASH_URL
static final String SPLASH_URL
Template forgetSplashUrl()
.- See Also:
- Constant Field Values
-
BANNER_URL
static final String BANNER_URL
Template forgetBannerUrl()
.- See Also:
- Constant Field Values
-
-
Method Detail
-
retrieveRegions
@Nonnull @CheckReturnValue default RestAction<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
@Nonnull @CheckReturnValue RestAction<EnumSet<Region>> retrieveRegions(boolean includeDeprecated)
Retrieves the available regions for this Guild- Parameters:
includeDeprecated
- Whether to include deprecated regions- Returns:
RestAction
- TypeEnumSet
-
addMember
@Nonnull @CheckReturnValue MemberAction addMember(@Nonnull String accessToken, @Nonnull 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:
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
@Nonnull @CheckReturnValue default MemberAction addMember(@Nonnull String accessToken, @Nonnull 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:
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
@Nonnull @CheckReturnValue default MemberAction addMember(@Nonnull 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:
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
-
isLoaded
boolean isLoaded()
Whether this guild has loaded members.
This will always be false if theGUILD_MEMBERS
intent is disabled.- Returns:
- True, if members are loaded.
-
pruneMemberCache
void pruneMemberCache()
Re-apply theMemberCachePolicy
of this session to allMembers
of this Guild.Example
// Check if the members of this guild have at least 50% bots (bot collection/farm) public void checkBots(Guild guild) { // Keep in mind: This requires the GUILD_MEMBERS intent which is disabled in createDefault and createLight by default guild.retrieveMembers() // Load members CompletableFuture<Void> (async and eager) .thenApply((v) -> guild.getMemberCache()) // Turn into CompletableFuture<MemberCacheView> .thenAccept((members) -> { int total = members.size(); // Casting to double to get a double as result of division, don't need to worry about precision with small counts like this double bots = (double) members.applyStream(stream -> stream.map(Member::getUser) .filter(User::isBot) .count()); // Count bots if (bots / total > 0.5) // Check how many members are bots System.out.println("More than 50% of members in this guild are bots"); }) .thenRun(guild::pruneMemberCache); // Then prune the cache }
- See Also:
unloadMember(long)
,JDA.unloadUser(long)
-
unloadMember
boolean unloadMember(long userId)
Attempts to remove the user with the provided id from the member cache.
If you attempt to remove theSelfUser
this will simply returnfalse
.This should be used by an implementation of
MemberCachePolicy
as an upstream request to remove a member. For example a Least-Recently-Used (LRU) cache might use this to drop old members if the cache capacity is reached. Or a timeout cache could use this to remove expired members.- Parameters:
userId
- The target user id- Returns:
- True, if the cache was changed
- See Also:
pruneMemberCache()
,JDA.unloadUser(long)
-
getMemberCount
int getMemberCount()
The expected member count for this guild.
If this guild is not lazy loaded this should be identical to the size returned bygetMemberCache()
.When
GatewayIntent.GUILD_MEMBERS
is disabled, this will not be updated.- Returns:
- The expected member count for this guild
-
getName
@Nonnull 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
@Nullable 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
@Nullable default 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
@Nonnull Set<String> getFeatures()
The Features of theGuild
.Possible known features:
- ANIMATED_ICON - Guild can have an animated icon
- BANNER - Guild can have a banner
- COMMERCE - Guild can sell software through a store channel
- DISCOVERABLE - Guild shows up in discovery tab
- INVITE_SPLASH - Guild has custom invite splash. See
getSplashId()
andgetSplashUrl()
- MORE_EMOJI - Guild is able to use more than 50 emoji
- NEWS - Guild can create news channels
- PARTNERED - Guild is "partnered"
- PUBLIC - Guild is public
- VANITY_URL - Guild a vanity URL (custom invite link). See
getVanityUrl()
- VERIFIED - Guild is "verified"
- VIP_REGIONS - Guild has VIP voice regions
- Returns:
- Never-null, unmodifiable Set containing all of the Guild's features.
-
getSplashId
@Nullable 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
@Nullable default 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.
-
retrieveVanityUrl
@Nonnull @Deprecated @ForRemoval @DeprecatedSince("4.0.0") @ReplaceWith("getVanityCode()") @CheckReturnValue RestAction<String> retrieveVanityUrl()
Deprecated.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 discrepancy
- Returns:
RestAction
- Type: String
The vanity url of this server- Throws:
InsufficientPermissionException
- If the logged in account does not have theMANAGE_SERVER
permission.IllegalStateException
- If the guild doesn't have the VANITY_URL feature- See Also:
getFeatures()
,getVanityCode()
-
getVanityCode
@Nullable String getVanityCode()
The vanity url code for this Guild. The vanity url is the custom invite code of partnered / official / boosted Guilds.
The returned String will be the code that can be provided todiscord.gg/{code}
to get the invite link.The Vanity Code can be modified using
GuildManager.setVanityCode(String)
.- Returns:
- The vanity code or null
- Since:
- 4.0.0
- See Also:
getVanityUrl()
-
getVanityUrl
@Nullable default String getVanityUrl()
The vanity url for this Guild. The vanity url is the custom invite code of partnered / official / boosted Guilds.
The returned String will be the vanity invite link to this guild.The Vanity Code can be modified using
GuildManager.setVanityCode(String)
.- Returns:
- The vanity url or null
- Since:
- 4.0.0
-
getDescription
@Nullable String getDescription()
The description for this guild.
This is displayed in the server browser below the guild name for verified guilds.The description can be modified using
GuildManager.setDescription(String)
.- Returns:
- The description
- Since:
- 4.0.0
-
getLocale
@Nonnull Locale getLocale()
The preferred locale for this guild.- Returns:
- The preferred
Locale
for this guild
-
getBannerId
@Nullable String getBannerId()
The guild banner id.
This is shown in guilds below the guild name.The banner can be modified using
GuildManager.setBanner(Icon)
.- Returns:
- The guild banner id or null
- Since:
- 4.0.0
- See Also:
getBannerUrl()
-
getBannerUrl
@Nullable default String getBannerUrl()
The guild banner url.
This is shown in guilds below the guild name.The banner can be modified using
GuildManager.setBanner(Icon)
.- Returns:
- The guild banner url or null
- Since:
- 4.0.0
-
getBoostTier
@Nonnull Guild.BoostTier getBoostTier()
The boost tier for this guild.
Each tier unlocks new perks for a guild that can be seen in thefeatures
.- Returns:
- The boost tier.
- Since:
- 4.0.0
-
getBoostCount
int getBoostCount()
The amount of boosts this server currently has.- Returns:
- The boost count
- Since:
- 4.0.0
-
getBoosters
@Nonnull List<Member> getBoosters()
Sorted list ofMembers
that boost this guild.
The list is sorted byMember.getTimeBoosted()
ascending. This means the first element will be the member who has been boosting for the longest time.- Returns:
- Possibly-immutable list of members who boost this guild
-
getMaxBitrate
default int getMaxBitrate()
The maximum bitrate that can be applied to a voice channel in this guild.
This depends on the features of this guild that can be unlocked for partners or through boosting.- Returns:
- The maximum bitrate
- Since:
- 4.0.0
-
getMaxFileSize
default long getMaxFileSize()
Returns the maximum size for files that can be uploaded to this Guild. This returns 8 MiB for Guilds without a Boost Tier or Guilds with Boost Tier 1, 50 MiB for Guilds with Boost Tier 2 and 100 MiB for Guilds with Boost Tier 3.- Returns:
- The maximum size for files that can be uploaded to this Guild
- Since:
- 4.2.0
-
getMaxEmotes
default int getMaxEmotes()
The maximum amount of emotes a guild can have based on the guilds boost tier.- Returns:
- The maximum amount of emotes
- Since:
- 4.0.0
-
getMaxMembers
int getMaxMembers()
The maximum amount of members that can join this guild.- Returns:
- The maximum amount of members
- Since:
- 4.0.0
- See Also:
retrieveMetaData()
-
getMaxPresences
int getMaxPresences()
The maximum amount of connected members this guild can have at a time.
This includes members that are invisible but still connected to discord. If too many members are online the guild will become unavailable for others.- Returns:
- The maximum amount of connected members this guild can have
- Since:
- 4.0.0
- See Also:
retrieveMetaData()
-
retrieveMetaData
@Nonnull @CheckReturnValue RestAction<Guild.MetaData> retrieveMetaData()
LoadsGuild.MetaData
for this guild instance.- Returns:
RestAction
- Type:Guild.MetaData
- Since:
- 4.2.0
-
getAfkChannel
@Nullable 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
@Nullable 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
@Nullable Member getOwner()
TheMember
object for the owner of this Guild.
This is null when the owner is no longer in this guild or not yet loaded (lazy loading). Sometimes owners of guilds delete their account or get banned by Discord.If lazy-loading is used it is recommended to use
retrieveOwner()
instead.Ownership can be transferred using
transferOwnership(Member)
.This only works when the member was added to cache. Lazy loading might load this later.
SeeMemberCachePolicy
- Returns:
- Possibly-null Member object for the Guild owner.
- See Also:
getOwnerIdLong()
,retrieveOwner()
-
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
@Nonnull default 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
@Nonnull 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.api.entities.Guild.Timeout)
.- Returns:
- The
Timeout
set for this Guild.
-
getRegion
@Nonnull 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.api.Region)
.- Returns:
- The the audio Region this Guild is using for audio connections. Can return Region.UNKNOWN.
-
getRegionRaw
@Nonnull 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.api.Region)
.- Returns:
- Raw region name
-
isMember
boolean isMember(@Nonnull User user)
Used to determine if the providedUser
is a member of this Guild.This will only check cached members!
- 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
@Nonnull 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.
-
getMember
@Nullable Member getMember(@Nonnull User user)
Gets the Guild specificMember
object for the providedUser
.
If the user is not in this guild,null
is returned.This will only check cached members!
- Parameters:
user
- TheUser
which to retrieve a related Member object for.- Returns:
- Possibly-null
Member
for the relatedUser
. - Throws:
IllegalArgumentException
- If the provided user is null- See Also:
retrieveMember(User)
-
getMemberById
@Nullable default Member getMemberById(@Nonnull 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
.This will only check cached members!
- Parameters:
userId
- The Discord id of the User for which a Member object is requested.- Returns:
- Possibly-null
Member
with the relateduserId
. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
- See Also:
retrieveMemberById(String)
-
getMemberById
@Nullable 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
.This will only check cached members!
SeeMemberCachePolicy
- Parameters:
userId
- The Discord id of the User for which a Member object is requested.- Returns:
- Possibly-null
Member
with the relateduserId
. - See Also:
retrieveMemberById(long)
-
getMemberByTag
@Nullable default Member getMemberByTag(@Nonnull String tag)
Searches for aMember
that has the matching Discord Tag.
Format has to be in the formUsername#Discriminator
where the username must be between 2 and 32 characters (inclusive) matching the exact casing and the discriminator must be exactly 4 digits.
This does not check thenickname
of the member but the username.This will only check cached members!
SeeMemberCachePolicy
This only checks users that are in this guild. If a user exists with the tag that is not available in the
Member-Cache
it will not be detected.
Currently Discord does not offer a way to retrieve a user by their discord tag.- Parameters:
tag
- The Discord Tag in the formatUsername#Discriminator
- Returns:
- The
Member
for the discord tag or null if no member has the provided tag - Throws:
IllegalArgumentException
- If the provided tag is null or not in the described format- See Also:
JDA.getUserByTag(String)
-
getMemberByTag
@Nullable default Member getMemberByTag(@Nonnull String username, @Nonnull String discriminator)
Searches for aMember
that has the matching Discord Tag.
Format has to be in the formUsername#Discriminator
where the username must be between 2 and 32 characters (inclusive) matching the exact casing and the discriminator must be exactly 4 digits.
This does not check thenickname
of the member but the username.This will only check cached members!
SeeMemberCachePolicy
This only checks users that are in this guild. If a user exists with the tag that is not available in the
Member-Cache
it will not be detected.
Currently Discord does not offer a way to retrieve a user by their discord tag.- Parameters:
username
- The name of the userdiscriminator
- The discriminator of the user- Returns:
- The
Member
for the discord tag or null if no member has the provided tag - Throws:
IllegalArgumentException
- If the provided arguments are null or not in the described format- See Also:
getMemberByTag(String)
-
getMembers
@Nonnull default List<Member> getMembers()
A list of allMembers
in this Guild.
The Members are not provided in any particular order.This will only check cached members!
SeeMemberCachePolicy
This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getMemberCache()
and use its more efficient versions of handling these values.- Returns:
- Immutable list of all cached members in this Guild.
- See Also:
loadMembers()
-
getMembersByName
@Nonnull default List<Member> getMembersByName(@Nonnull 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.This will only check cached members!
SeeMemberCachePolicy
- 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.
- Throws:
IllegalArgumentException
- If the provided name is null- See Also:
retrieveMembersByPrefix(String, int)
-
getMembersByNickname
@Nonnull default List<Member> getMembersByNickname(@Nullable 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.This will only check cached members!
SeeMemberCachePolicy
- 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.
- See Also:
retrieveMembersByPrefix(String, int)
-
getMembersByEffectiveName
@Nonnull default List<Member> getMembersByEffectiveName(@Nonnull 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.This will only check cached members!
SeeMemberCachePolicy
- 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.
- Throws:
IllegalArgumentException
- If the provided name is null- See Also:
retrieveMembersByPrefix(String, int)
-
getMembersWithRoles
@Nonnull default List<Member> getMembersWithRoles(@Nonnull Role... roles)
Gets a list ofMembers
that have allRoles
provided.
If there are noMembers
with all provided roles, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy
- Parameters:
roles
- TheRoles
that aMember
must have to be included in the returned list.- Returns:
- Possibly-empty immutable list of Members with all provided Roles.
- Throws:
IllegalArgumentException
- If a providedRole
is from a different guild or null.
-
getMembersWithRoles
@Nonnull default List<Member> getMembersWithRoles(@Nonnull Collection<Role> roles)
Gets a list ofMembers
that have all providedRoles
.
If there are noMembers
with all provided roles, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy
- Parameters:
roles
- TheRoles
that aMember
must have to be included in the returned list.- Returns:
- Possibly-empty immutable list of Members with all provided Roles.
- Throws:
IllegalArgumentException
- If a providedRole
is from a different guild or null.
-
getMemberCache
@Nonnull MemberCacheView getMemberCache()
MemberCacheView
for all cachedMembers
of this Guild.This will only provide cached members!
SeeMemberCachePolicy
- Returns:
MemberCacheView
- See Also:
loadMembers()
-
getGuildChannelById
@Nullable default GuildChannel getGuildChannelById(@Nonnull String id)
GetGuildChannel
for the provided ID.
This checks if any of the channel types in this guild have the provided ID and returns the first match.
To get more specific channel types you can use one of the following:- Parameters:
id
- The ID of the channel- Returns:
- The GuildChannel or null
- Throws:
IllegalArgumentException
- If the provided ID is nullNumberFormatException
- If the provided ID is not a snowflake
-
getGuildChannelById
@Nullable default GuildChannel getGuildChannelById(long id)
GetGuildChannel
for the provided ID.
This checks if any of the channel types in this guild have the provided ID and returns the first match.
To get more specific channel types you can use one of the following:- Parameters:
id
- The ID of the channel- Returns:
- The GuildChannel or null
-
getGuildChannelById
@Nullable default GuildChannel getGuildChannelById(@Nonnull ChannelType type, @Nonnull String id)
GetGuildChannel
for the provided ID.
This is meant for systems that use a dynamicChannelType
and can profit from a simple function to get the channel instance. To get more specific channel types you can use one of the following:- Parameters:
type
- TheChannelType
id
- The ID of the channel- Returns:
- The GuildChannel or null
- Throws:
IllegalArgumentException
- If the provided ID is nullNumberFormatException
- If the provided ID is not a snowflake
-
getGuildChannelById
@Nullable default GuildChannel getGuildChannelById(@Nonnull ChannelType type, long id)
GetGuildChannel
for the provided ID.
This is meant for systems that use a dynamicChannelType
and can profit from a simple function to get the channel instance. To get more specific channel types you can use one of the following:- Parameters:
type
- TheChannelType
id
- The ID of the channel- Returns:
- The GuildChannel or null
-
getCategoryById
@Nullable default Category getCategoryById(@Nonnull 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:
IllegalArgumentException
- If the provided ID is not a validlong
-
getCategoryById
@Nullable 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
@Nonnull default List<Category> getCategories()
Gets allCategories
in thisGuild
.
The returned categories will be sorted according to their position.This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getCategoryCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable list of all
Categories
in this Guild.
-
getCategoriesByName
@Nonnull default List<Category> getCategoriesByName(@Nonnull 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:
IllegalArgumentException
- If the provided name isnull
-
getCategoryCache
@Nonnull SortedSnowflakeCacheView<Category> getCategoryCache()
SortedSnowflakeCacheView
of all cachedCategories
of this Guild.
Categories are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getStoreChannelById
@Nullable default StoreChannel getStoreChannelById(@Nonnull String id)
Gets aStoreChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getStoreChannelById(String)
, but it only checks this specific Guild for a StoreChannel.
If there is noStoreChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theStoreChannel
.- Returns:
- Possibly-null
StoreChannel
with matching id. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
- Since:
- 4.0.0
-
getStoreChannelById
@Nullable default StoreChannel getStoreChannelById(long id)
Gets aStoreChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getStoreChannelById(long)
, but it only checks this specific Guild for a StoreChannel.
If there is noStoreChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theStoreChannel
.- Returns:
- Possibly-null
StoreChannel
with matching id. - Since:
- 4.0.0
-
getStoreChannels
@Nonnull default List<StoreChannel> getStoreChannels()
Gets allStoreChannels
in thisGuild
.
The channels returned will be sorted according to their position.This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getStoreChannelCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of all
StoreChannel
in this Guild. - Since:
- 4.0.0
-
getStoreChannelsByName
@Nonnull default List<StoreChannel> getStoreChannelsByName(@Nonnull String name, boolean ignoreCase)
Gets a list of allStoreChannels
in this Guild that have the same name as the one provided.
If there are noStoreChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedStoreChannels
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all StoreChannels with names that match the provided name.
- Since:
- 4.0.0
-
getStoreChannelCache
@Nonnull SortedSnowflakeCacheView<StoreChannel> getStoreChannelCache()
SortedSnowflakeCacheView
of all cachedStoreChannels
of this Guild.
TextChannels are sorted according to their position.- Returns:
SortedSnowflakeCacheView
- Since:
- 4.0.0
-
getTextChannelById
@Nullable default TextChannel getTextChannelById(@Nonnull 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:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getTextChannelById
@Nullable 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
@Nonnull default List<TextChannel> getTextChannels()
Gets allTextChannels
in thisGuild
.
The channels returned will be sorted according to their position.This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getTextChannelCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of all
TextChannels
in this Guild.
-
getTextChannelsByName
@Nonnull default List<TextChannel> getTextChannelsByName(@Nonnull 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
@Nonnull SortedSnowflakeCacheView<TextChannel> getTextChannelCache()
SortedSnowflakeCacheView
of all cachedTextChannels
of this Guild.
TextChannels are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getVoiceChannelById
@Nullable default VoiceChannel getVoiceChannelById(@Nonnull 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:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getVoiceChannelById
@Nullable 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
@Nonnull default List<VoiceChannel> getVoiceChannels()
Gets allVoiceChannels
in thisGuild
.
The channels returned will be sorted according to their position.This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getVoiceChannelCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of
VoiceChannels
.
-
getVoiceChannelsByName
@Nonnull default List<VoiceChannel> getVoiceChannelsByName(@Nonnull 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
@Nonnull SortedSnowflakeCacheView<VoiceChannel> getVoiceChannelCache()
SortedSnowflakeCacheView
of all cachedVoiceChannels
of this Guild.
VoiceChannels are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getChannels
@Nonnull default List<GuildChannel> 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 and StoreChannel without parent
- VoiceChannel without parent
- Categories
- TextChannel and StoreChannel with category as parent
- VoiceChannel with category as parent
- Returns:
- Immutable list of channels for this guild
- See Also:
getChannels(boolean)
-
getChannels
@Nonnull List<GuildChannel> 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 and StoreChannel without parent
- VoiceChannel without parent
- Categories
- TextChannel and StoreChannel 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
@Nullable default Role getRoleById(@Nonnull String id)
Gets aRole
from this guild that has the same id as the one provided.
If there is noRole
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theRole
.- Returns:
- Possibly-null
Role
with matching id. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getRoles
@Nonnull default List<Role> getRoles()
Gets allRoles
in thisGuild
.
The roles returned will be sorted according to their position. The highest role being at index 0 and the lowest at the last index.This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getRoleCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of
Roles
.
-
getRolesByName
@Nonnull default List<Role> getRolesByName(@Nonnull 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
@Nonnull SortedSnowflakeCacheView<Role> getRoleCache()
SortedSnowflakeCacheView
of all cachedRoles
of this Guild.
Roles are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getEmoteById
@Nullable default Emote getEmoteById(@Nonnull 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
.Unicode emojis are not included as
Emote
!This requires the
CacheFlag.EMOTE
to be enabled!- Parameters:
id
- the emote id- Returns:
- An Emote matching the specified Id.
- Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
- See Also:
retrieveEmoteById(String)
-
getEmoteById
@Nullable 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
.Unicode emojis are not included as
Emote
!This requires the
CacheFlag.EMOTE
to be enabled!- Parameters:
id
- the emote id- Returns:
- An Emote matching the specified Id.
- See Also:
retrieveEmoteById(long)
-
getEmotes
@Nonnull default 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
!This copies the backing store into a list. This means every call creates a new list with O(n) complexity. It is recommended to store this into a local variable or use
getEmoteCache()
and use its more efficient versions of handling these values.This requires the
CacheFlag.EMOTE
to be enabled!- Returns:
- An immutable List of
Emotes
. - See Also:
retrieveEmotes()
-
getEmotesByName
@Nonnull default List<Emote> getEmotesByName(@Nonnull 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.Unicode emojis are not included as
Emote
!This requires the
CacheFlag.EMOTE
to be enabled!- Parameters:
name
- The name used to filter the returnedEmotes
. Without colons.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Emotes that match the provided name.
-
getEmoteCache
@Nonnull SnowflakeCacheView<Emote> getEmoteCache()
SnowflakeCacheView
of all cachedEmotes
of this Guild.
This will be empty ifCacheFlag.EMOTE
is disabled.This requires the
CacheFlag.EMOTE
to be enabled!- Returns:
SnowflakeCacheView
- See Also:
retrieveEmotes()
-
retrieveEmotes
@Nonnull @CheckReturnValue RestAction<List<ListedEmote>> retrieveEmotes()
Retrieves an immutable 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 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:
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
-
retrieveBanList
@Nonnull @CheckReturnValue RestAction<List<Guild.Ban>> retrieveBanList()
Retrieves an immutable list of the currently bannedUsers
.
If you wish to ban or unban a user, use eitherban(User, int)
orunban(User)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancy
- Returns:
RestAction
- Type: List<Ban
>
Retrieves an immutable list of all users currently banned from this Guild- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.
-
retrieveBanById
@Nonnull @CheckReturnValue default RestAction<Guild.Ban> retrieveBanById(long userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherban(String, int)
ban(id, int)} orunban(String)
unban(id)}.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyUNKNOWN_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.
-
retrieveBanById
@Nonnull @CheckReturnValue RestAction<Guild.Ban> retrieveBanById(@Nonnull String userId)
Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherban(id, int)
orunban(id)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyUNKNOWN_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.
-
retrieveBan
@Nonnull @CheckReturnValue default RestAction<Guild.Ban> retrieveBan(@Nonnull User bannedUser)
Retrieves aBan
of the providedUser
If you wish to ban or unban a user, use eitherban(User, int)
orunban(User)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyUNKNOWN_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.
-
retrievePrunableMemberCount
@Nonnull @CheckReturnValue RestAction<Integer> retrievePrunableMemberCount(int days)
The method calculates the amount of Members that would be pruned ifprune(int, Role...)
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 discrepancy
- 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.IllegalArgumentException
- If the provided days are less than1
or more than30
-
getPublicRole
@Nonnull 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
@Nonnull 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
-
retrieveAuditLogs
@Nonnull @CheckReturnValue AuditLogPaginationAction retrieveAuditLogs()
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 void logBan(GuildBanEvent event) { Guild guild = event.getGuild(); List<TextChannel> modLog = guild.getTextChannelsByName("mod-log", true); guild.retrieveAuditLogs() .type(ActionType.BAN) // filter by type .limit(1) .queue(list -> { if (list.isEmpty()) return; AuditLogEntry entry = list.get(0); String message = String.format("%#s banned %#s with reason %s", entry.getUser(), event.getUser(), entry.getReason()); modLog.forEach(channel -> channel.sendMessage(message).queue() ); }); }
- Returns:
AuditLogPaginationAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have the permissionVIEW_AUDIT_LOGS
-
leave
@Nonnull @CheckReturnValue RestAction<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 usingtransferOwnership(Member)
.- Returns:
RestAction
- Type:Void
- Throws:
IllegalStateException
- Thrown if the currently logged in account is the Owner of this Guild.
-
delete
@Nonnull @CheckReturnValue RestAction<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.IllegalStateException
- If the currently logged in account has MFA enabled. (SelfUser.isMfaEnabled()
).
-
delete
@Nonnull @CheckReturnValue RestAction<Void> delete(@Nullable 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.IllegalArgumentException
- If the providedmfaCode
isnull
or empty whenSelfUser.isMfaEnabled()
is true.
-
getAudioManager
@Nonnull 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.
- Throws:
IllegalStateException
- IfGatewayIntent.GUILD_VOICE_STATES
is disabled- See Also:
JDA.getAudioManagerCache()
-
getJDA
@Nonnull JDA getJDA()
Returns theJDA
instance of this Guild- Returns:
- the corresponding JDA instance
-
retrieveInvites
@Nonnull @CheckReturnValue RestAction<List<Invite>> retrieveInvites()
Retrieves allInvites
for this guild.
RequiresMANAGE_SERVER
in this guild. Will throw aInsufficientPermissionException
otherwise.To get all invites for a
GuildChannel
useGuildChannel.retrieveInvites()
- 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:
GuildChannel.retrieveInvites()
-
retrieveWebhooks
@Nonnull @CheckReturnValue RestAction<List<Webhook>> retrieveWebhooks()
Retrieves allWebhooks
for this Guild.
RequiresMANAGE_WEBHOOKS
in this Guild.To get all webhooks for a specific
TextChannel
, useTextChannel.retrieveWebhooks()
- 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.retrieveWebhooks()
-
getVoiceStates
@Nonnull 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 immutable list containing all the
GuildVoiceStates
on thisGuild
.
-
getVerificationLevel
@Nonnull 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.api.entities.Guild.VerificationLevel)
.- Returns:
- The Verification-Level of this Guild.
-
getDefaultNotificationLevel
@Nonnull 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.api.entities.Guild.NotificationLevel)
.- Returns:
- The default message Notification-Level of this Guild.
-
getRequiredMFALevel
@Nonnull 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.api.entities.Guild.MFALevel)
.- Returns:
- The MFA-Level required by this Guild.
-
getExplicitContentLevel
@Nonnull 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
@Deprecated @ForRemoval @DeprecatedSince("4.2.0") boolean checkVerification()
Deprecated.Bots don't need to check this and client accounts are not supportedChecks 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
@ForRemoval @Deprecated @DeprecatedSince("4.1.0") @ReplaceWith("getJDA().isUnavailable(guild.getIdLong())") boolean isAvailable()
Deprecated.This will be removed in a future version, unavailable guilds are now removed from cache. Replace withJDA.isUnavailable(long)
Whether or not this Guild is available. A Guild can be unavailable, if the Discord server has problems.
If a Guild is unavailable, it will be removed from the guild cache. You cannot receive events for unavailable guilds.- Returns:
- If the Guild is available
-
retrieveMembers
@Nonnull @Deprecated @DeprecatedSince("4.2.0") @ReplaceWith("loadMembers(Consumer<Member>) or loadMembers()") CompletableFuture<Void> retrieveMembers()
Deprecated.Requests member chunks for this guild.
This returns a completed future if the member demand is already matched. WhenGatewayIntent.GUILD_MEMBERS
is disabled this will do nothing sincegetMemberCount()
cannot be tracked.Calling
CompletableFuture.cancel(boolean)
will not cancel the chunking process.You MUST NOT use blocking operations such as
CompletableFuture.join()
orFuture.get()
! The response handling happens on the event thread by default.- Returns:
CompletableFuture
representing the chunking task- See Also:
pruneMemberCache()
-
loadMembers
@Nonnull @CheckReturnValue default Task<List<Member>> loadMembers()
Retrieves and collects members of this guild into a list.
This will use the configuredMemberCachePolicy
to decide which members to retain in cache.You can use
findMembers(Predicate)
to filter specific members.This requires the privileged GatewayIntent.GUILD_MEMBERS to be enabled!
You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Returns:
Task
- Type:List
ofMember
- Throws:
IllegalStateException
- If theGatewayIntent.GUILD_MEMBERS
is not enabled
-
findMembers
@Nonnull @CheckReturnValue default Task<List<Member>> findMembers(@Nonnull Predicate<? super Member> filter)
Retrieves and collects members of this guild into a list.
This will use the configuredMemberCachePolicy
to decide which members to retain in cache.This requires the privileged GatewayIntent.GUILD_MEMBERS to be enabled!
You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
filter
- Filter to decide which members to include- Returns:
Task
- Type:List
ofMember
- Throws:
IllegalArgumentException
- If the provided filter is nullIllegalStateException
- If theGatewayIntent.GUILD_MEMBERS
is not enabled
-
loadMembers
@Nonnull Task<Void> loadMembers(@Nonnull Consumer<Member> callback)
Retrieves all members of this guild.
This will use the configuredMemberCachePolicy
to decide which members to retain in cache.This requires the privileged GatewayIntent.GUILD_MEMBERS to be enabled!
You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
callback
- Consumer callback for each member- Returns:
Task
cancellable handle for this request- Throws:
IllegalArgumentException
- If the callback is nullIllegalStateException
- If theGatewayIntent.GUILD_MEMBERS
is not enabled
-
retrieveMember
@Nonnull default RestAction<Member> retrieveMember(@Nonnull User user)
Load the member for the specified user.
If the member is already loaded it will be retrieved fromgetMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can passupdate = false
to always return immediately if the member is cached regardless of cache consistency.When the intent
GUILD_MEMBERS
is disabled this will always make a request even if the member is cached. You can useretrieveMember(User, boolean)
to disable this behavior.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
user
- The user to load the member from- Returns:
RestAction
- Type:Member
- Throws:
IllegalArgumentException
- If provided with null- See Also:
pruneMemberCache()
,unloadMember(long)
-
retrieveMemberById
@Nonnull default RestAction<Member> retrieveMemberById(@Nonnull String id)
Load the member for the specified user.
If the member is already loaded it will be retrieved fromgetMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can passupdate = false
to always return immediately if the member is cached regardless of cache consistency.When the intent
GUILD_MEMBERS
is disabled this will always make a request even if the member is cached. You can useretrieveMemberById(String, boolean)
to disable this behavior.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
id
- The user id to load the member from- Returns:
RestAction
- Type:Member
- Throws:
IllegalArgumentException
- If the provided id is empty or nullNumberFormatException
- If the provided id is not a snowflake- See Also:
pruneMemberCache()
,unloadMember(long)
-
retrieveMemberById
@Nonnull default RestAction<Member> retrieveMemberById(long id)
Load the member for the specified user.
If the member is already loaded it will be retrieved fromgetMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can passupdate = false
to always return immediately if the member is cached regardless of cache consistency.When
GatewayIntent.GUILD_MEMBERS
is disabled this will always make a request even if the member is cached. You can useretrieveMemberById(long, boolean)
to disable this behavior.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
id
- The user id to load the member from- Returns:
RestAction
- Type:Member
- See Also:
pruneMemberCache()
,unloadMember(long)
-
retrieveOwner
@Nonnull default RestAction<Member> retrieveOwner()
Shortcut forguild.retrieveMemberById(guild.getOwnerIdLong())
.
This will retrieve the current owner of the guild. It is possible that the owner of a guild is no longer a registered discord user in which case this will fail.When
GatewayIntent.GUILD_MEMBERS
is disabled this will always make a request even if the member is cached. You can useretrieveOwner(boolean)
to disable this behavior.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Returns:
RestAction
- Type:Member
- See Also:
pruneMemberCache()
,unloadMember(long)
,getOwner()
,getOwnerIdLong()
,retrieveMemberById(long)
-
retrieveMember
@Nonnull default RestAction<Member> retrieveMember(@Nonnull User user, boolean update)
Load the member for the specified user.
If the member is already loaded it will be retrieved fromgetMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can passupdate = false
to always return immediately if the member is cached regardless of cache consistency.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
user
- The user to load the member fromupdate
- Whether JDA should perform a request even if the member is already cached to update properties such as the name- Returns:
RestAction
- Type:Member
- Throws:
IllegalArgumentException
- If provided with null- See Also:
pruneMemberCache()
,unloadMember(long)
-
retrieveMemberById
@Nonnull default RestAction<Member> retrieveMemberById(@Nonnull String id, boolean update)
Load the member for the specified user.
If the member is already loaded it will be retrieved fromgetMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can passupdate = false
to always return immediately if the member is cached regardless of cache consistency.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
id
- The user id to load the member fromupdate
- Whether JDA should perform a request even if the member is already cached to update properties such as the name- Returns:
RestAction
- Type:Member
- Throws:
IllegalArgumentException
- If the provided id is empty or nullNumberFormatException
- If the provided id is not a snowflake- See Also:
pruneMemberCache()
,unloadMember(long)
-
retrieveMemberById
@Nonnull RestAction<Member> retrieveMemberById(long id, boolean update)
Load the member for the specified user.
If the member is already loaded it will be retrieved fromgetMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can passupdate = false
to always return immediately if the member is cached regardless of cache consistency.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
id
- The user id to load the member fromupdate
- Whether JDA should perform a request even if the member is already cached to update properties such as the name- Returns:
RestAction
- Type:Member
- See Also:
pruneMemberCache()
,unloadMember(long)
-
retrieveOwner
@Nonnull default RestAction<Member> retrieveOwner(boolean update)
Shortcut forguild.retrieveMemberById(guild.getOwnerIdLong())
.
This will retrieve the current owner of the guild. It is possible that the owner of a guild is no longer a registered discord user in which case this will fail.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
update
- Whether JDA should perform a request even if the member is already cached to update properties such as the name- Returns:
RestAction
- Type:Member
- See Also:
pruneMemberCache()
,unloadMember(long)
,getOwner()
,getOwnerIdLong()
,retrieveMemberById(long)
-
retrieveMembers
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembers(@Nonnull Collection<User> users)
Retrieves a list of members.
If the user does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the users resolve to a member, in which case an empty list will be the result.If the
GUILD_PRESENCES
intent is enabled, this will load theOnlineStatus
andActivities
of the members. You can useretrieveMembers(boolean, Collection)
to disable presences.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
users
- The users of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If the input contains null
- If the input is more than 100 IDs
-
retrieveMembersByIds
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembersByIds(@Nonnull Collection<Long> ids)
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.If the
GUILD_PRESENCES
intent is enabled, this will load theOnlineStatus
andActivities
of the members. You can useretrieveMembersByIds(boolean, Collection)
to disable presences.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
ids
- The ids of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If the input contains null
- If the input is more than 100 IDs
-
retrieveMembersByIds
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembersByIds(@Nonnull String... ids)
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.If the
GUILD_PRESENCES
intent is enabled, this will load theOnlineStatus
andActivities
of the members. You can useretrieveMembersByIds(boolean, String...)
to disable presences.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
ids
- The ids of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If the input contains null
- If the input is more than 100 IDs
-
retrieveMembersByIds
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembersByIds(@Nonnull long... ids)
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.If the
GUILD_PRESENCES
intent is enabled, this will load theOnlineStatus
andActivities
of the members. You can useretrieveMembersByIds(boolean, long...)
to disable presences.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
ids
- The ids of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If the input contains null
- If the input is more than 100 IDs
-
retrieveMembers
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembers(boolean includePresence, @Nonnull Collection<User> users)
Retrieves a list of members.
If the user does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the users resolve to a member, in which case an empty list will be the result.You can only load presences with the
GUILD_PRESENCES
intent enabled.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
includePresence
- Whether to load presences of the members (online status/activity)users
- The users of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If includePresence is
true
and the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
-
retrieveMembersByIds
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembersByIds(boolean includePresence, @Nonnull Collection<Long> ids)
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.You can only load presences with the
GUILD_PRESENCES
intent enabled.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
includePresence
- Whether to load presences of the members (online status/activity)ids
- The ids of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If includePresence is
true
and the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
-
retrieveMembersByIds
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembersByIds(boolean includePresence, @Nonnull String... ids)
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.You can only load presences with the
GUILD_PRESENCES
intent enabled.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
includePresence
- Whether to load presences of the members (online status/activity)ids
- The ids of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If includePresence is
true
and the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
-
retrieveMembersByIds
@Nonnull @CheckReturnValue Task<List<Member>> retrieveMembersByIds(boolean includePresence, @Nonnull long... ids)
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.You can only load presences with the
GUILD_PRESENCES
intent enabled.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
includePresence
- Whether to load presences of the members (online status/activity)ids
- The ids of the members (max 100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If includePresence is
true
and the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
-
retrieveMembersByPrefix
@Nonnull @CheckReturnValue Task<List<Member>> retrieveMembersByPrefix(@Nonnull String prefix, int limit)
Queries a list of members using a radix tree based on the provided name prefix.
This will check both the username and the nickname of the members. Additional filtering may be required. If no members with the specified prefix exist, the list will be empty.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Parameters:
prefix
- The case-insensitive name prefixlimit
- The max amount of members to retrieve (1-100)- Returns:
Task
handle for the request- Throws:
IllegalArgumentException
-- If the provided prefix is null or empty.
- If the provided limit is not in the range of [1, 100]
- See Also:
getMembersByName(String, boolean)
,getMembersByNickname(String, boolean)
,getMembersByEffectiveName(String, boolean)
-
moveVoiceMember
@Nonnull @CheckReturnValue RestAction<Void> moveVoiceMember(@Nonnull Member member, @Nullable VoiceChannel voiceChannel)
Used to move aMember
from oneVoiceChannel
to anotherVoiceChannel
.
As a note, you cannot move a Member that isn't already in a VoiceChannel. Also they must be in a VoiceChannel in the same Guild as the one that you are moving them to.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be moved due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission was removedUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUNKNOWN_CHANNEL
The specified channel was deleted before finishing the task
- Parameters:
member
- TheMember
that you are moving.voiceChannel
- The destinationVoiceChannel
to which the member is being moved to. Or null to perform a voice kick.- Returns:
RestAction
- Throws:
IllegalStateException
- If the Member isn't currently in a VoiceChannel in this Guild, orCacheFlag.VOICE_STATE
is disabled.IllegalArgumentException
-InsufficientPermissionException
-- If this account doesn't have
Permission.VOICE_MOVE_OTHERS
in the VoiceChannel that the Member is currently in. - If this account AND the Member being moved don't have
Permission.VOICE_CONNECT
for the destination VoiceChannel.
- If this account doesn't have
-
kickVoiceMember
@Nonnull @CheckReturnValue default RestAction<Void> kickVoiceMember(@Nonnull Member member)
Used to kick aMember
from aVoiceChannel
.
As a note, you cannot kick a Member that isn't already in a VoiceChannel. Also they must be in a VoiceChannel in the same Guild.Equivalent to
moveVoiceMember(member, null)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be moved due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUNKNOWN_CHANNEL
The specified channel was deleted before finishing the task
- Parameters:
member
- TheMember
that you are moving.- Returns:
RestAction
- Throws:
IllegalStateException
- If the Member isn't currently in a VoiceChannel in this Guild, orCacheFlag.VOICE_STATE
is disabled.IllegalArgumentException
-InsufficientPermissionException
- If this account doesn't havePermission.VOICE_MOVE_OTHERS
in the VoiceChannel that the Member is currently in.
-
modifyNickname
@Nonnull @CheckReturnValue AuditableRestAction<Void> modifyNickname(@Nonnull Member member, @Nullable String nickname)
Changes the Member's nickname in this guild. The nickname is visible to all members of this guild.To change the nickname for the currently logged in account only the Permission
NICKNAME_CHANGE
is required.
To change the nickname of anyMember
for thisGuild
the PermissionNICKNAME_MANAGE
is required.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The nickname of the target Member is not modifiable due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- TheMember
for which the nickname should be changed.nickname
- The new nickname of theMember
, providenull
or an empty String to reset the nickname- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
- If the specifiedMember
is not from the sameGuild
. Or if the provided member isnull
InsufficientPermissionException
-- If attempting to set nickname for self and the logged in account has neither
Permission.NICKNAME_CHANGE
orPermission.NICKNAME_MANAGE
- If attempting to set nickname for another member and the logged in account does not have
Permission.NICKNAME_MANAGE
- If attempting to set nickname for self and the logged in account has neither
HierarchyException
- If attempting to set nickname for another member and the logged in account cannot manipulate the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
-
prune
@Nonnull @CheckReturnValue default AuditableRestAction<Integer> prune(int days, @Nonnull Role... roles)
This method will prune (kick) all members who were offline for at least days days.
The RestAction returned from this method will return the amount of Members that were pruned.
You can useretrievePrunableMemberCount(int)
to determine how many Members would be pruned if you were to call this method.This might timeout when pruning many members. You can use
prune(days, false)
to ignore the prune count and avoid a timeout.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The prune cannot finished due to a permission discrepancy
- Parameters:
days
- Minimum number of days since a member has been offline to get affected.roles
- Optional roles to include in prune filter- Returns:
AuditableRestAction
- Type: Integer
The amount of Members that were pruned from the Guild.- Throws:
InsufficientPermissionException
- If the account doesn't haveKICK_MEMBER
Permission.IllegalArgumentException
-- If the provided days are not in the range from 1 to 30 (inclusive)
- If null is provided
- If any of the provided roles is not from this guild
-
prune
@Nonnull @CheckReturnValue AuditableRestAction<Integer> prune(int days, boolean wait, @Nonnull Role... roles)
This method will prune (kick) all members who were offline for at least days days.
The RestAction returned from this method will return the amount of Members that were pruned.
You can useretrievePrunableMemberCount(int)
to determine how many Members would be pruned if you were to call this method.This might timeout when pruning many members with
wait=true
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The prune cannot finished due to a permission discrepancy
- Parameters:
days
- Minimum number of days since a member has been offline to get affected.wait
- Whether to calculate the number of pruned members and wait for the response (timeout for too many pruned)roles
- Optional roles to include in prune filter- Returns:
AuditableRestAction
- Type: Integer
Provides the amount of Members that were pruned from the Guild, if wait is true.- Throws:
InsufficientPermissionException
- If the account doesn't haveKICK_MEMBER
Permission.IllegalArgumentException
-- If the provided days are not in the range from 1 to 30 (inclusive)
- If null is provided
- If any of the provided roles is not from this guild
-
kick
@Nonnull @CheckReturnValue AuditableRestAction<Void> kick(@Nonnull Member member, @Nullable String reason)
Kicks theMember
from theGuild
.Note:
getMembers()
will still contain theUser
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be kicked due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- TheMember
to kick from the from theGuild
.reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
Kicks the provided Member from the current Guild- Throws:
IllegalArgumentException
- If the provided member is not a Member of this Guild or isnull
InsufficientPermissionException
- If the logged in account does not have thePermission.KICK_MEMBERS
permission.HierarchyException
- If the logged in account cannot kick the other member due to permission hierarchy position.
SeeMember.canInteract(Member)
-
kick
@Nonnull @CheckReturnValue AuditableRestAction<Void> kick(@Nonnull String userId, @Nullable String reason)
Kicks theMember
specified by the userId from the from theGuild
.Note:
getMembers()
will still contain theUser
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be kicked due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The id of theUser
to kick from the from theGuild
.reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.KICK_MEMBERS
permission.HierarchyException
- If the logged in account cannot kick the other member due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
- If the user for the provided id cannot be kicked from this Guild or the provideduserId
is blank/null.
-
kick
@Nonnull @CheckReturnValue default AuditableRestAction<Void> kick(@Nonnull Member member)
Kicks aMember
from theGuild
.Note:
getMembers()
will still contain theUser
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be kicked due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- TheMember
to kick from the from theGuild
.- Returns:
AuditableRestAction
Kicks the provided Member from the current Guild- Throws:
IllegalArgumentException
- If the provided member is not a Member of this Guild or isnull
InsufficientPermissionException
- If the logged in account does not have thePermission.KICK_MEMBERS
permission.HierarchyException
- If the logged in account cannot kick the other member due to permission hierarchy position.
SeeMember.canInteract(Member)
-
kick
@Nonnull @CheckReturnValue default AuditableRestAction<Void> kick(@Nonnull String userId)
Kicks theMember
specified by the userId from the from theGuild
.Note:
getMembers()
will still contain theUser
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be kicked due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The id of theUser
to kick from the from theGuild
.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.KICK_MEMBERS
permission.HierarchyException
- If the logged in account cannot kick the other member due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
- If the userId provided does not correspond to a Member in this Guild or the provideduserId
is blank/null.
-
ban
@Nonnull @CheckReturnValue AuditableRestAction<Void> ban(@Nonnull User user, int delDays, @Nullable String reason)
Bans theUser
and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a user without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
getMembers()
will still contain theUser's
Member
object (if the User was in the Guild) until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
user
- TheUser
to ban.delDays
- The history of messages, in days, that will be deleted.reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided user is null
-
ban
@Nonnull @CheckReturnValue AuditableRestAction<Void> ban(@Nonnull String userId, int delDays, @Nullable String reason)
Bans the user specified by the userId and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a user without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
getMembers()
will still contain theUser's
Member
object (if the User was in the Guild) until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_USER
The specified User does not exit
- Parameters:
userId
- The id of theUser
to ban.delDays
- The history of messages, in days, that will be deleted.reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided userId is null
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(@Nonnull Member member, int delDays, @Nullable String reason)
Bans theMember
and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a member without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
getMembers()
will still contain theMember
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- TheMember
to ban.delDays
- The history of messages, in days, that will be deleted.reason
- The reason for this action ornull
if there is no specified reason- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided member is
null
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(@Nonnull Member member, int delDays)
Bans theMember
and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a member without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
getMembers()
will still contain theMember
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- TheMember
to ban.delDays
- The history of messages, in days, that will be deleted.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided member is
null
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(@Nonnull User user, int delDays)
Bans theMember
and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a member without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
getMembers()
will still contain theMember
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
user
- TheUser
to ban.delDays
- The history of messages, in days, that will be deleted.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided user is
null
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> ban(@Nonnull String userId, int delDays)
Bans the user specified by the userId and deletes messages sent by the user based on the amount of delDays.
If you wish to ban a user without deleting any messages, provide delDays with a value of 0.You can unban a user with
Guild.unban(User)
.Note:
getMembers()
will still contain theUser's
Member
object (if the User was in the Guild) until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The id of theUser
to ban.delDays
- The history of messages, in days, that will be deleted.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.HierarchyException
- If the logged in account cannot ban the other user due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
-- If the provided amount of days (delDays) is less than 0.
- If the provided amount of days (delDays) is bigger than 7.
- If the provided userId is
null
-
unban
@Nonnull @CheckReturnValue default AuditableRestAction<Void> unban(@Nonnull User user)
Unbans the specifiedUser
from this Guild.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be unbanned due to a permission discrepancyUNKNOWN_USER
The specified User is invalid
- Parameters:
user
- The id of theUser
to unban.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.IllegalArgumentException
- If the provided user is null
-
unban
@Nonnull @CheckReturnValue AuditableRestAction<Void> unban(@Nonnull String userId)
Unbans the a user specified by the userId from this Guild.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be unbanned due to a permission discrepancyUNKNOWN_USER
The specified User does not exist
- Parameters:
userId
- The id of theUser
to unban.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.IllegalArgumentException
- If the provided id is null or blank
-
deafen
@Nonnull @CheckReturnValue AuditableRestAction<Void> deafen(@Nonnull Member member, boolean deafen)
Sets the Guild Deafened state state of theMember
based on the provided boolean.Note: The Member's
GuildVoiceState.isGuildDeafened()
value won't change until JDA receives theGuildVoiceGuildDeafenEvent
event related to this change.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be deafened due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUSER_NOT_CONNECTED
The specified Member is not connected to a voice channel
- Parameters:
member
- TheMember
who'sVoiceState
is being changed.deafen
- Whether thisMember
should be deafened or undeafened.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.VOICE_DEAF_OTHERS
permission.IllegalArgumentException
- If the provided member is not from this Guild or null.IllegalStateException
- If the provided member is not currently connected to a voice channel.
-
mute
@Nonnull @CheckReturnValue AuditableRestAction<Void> mute(@Nonnull Member member, boolean mute)
Sets the Guild Muted state state of theMember
based on the provided boolean.Note: The Member's
GuildVoiceState.isGuildMuted()
value won't change until JDA receives theGuildVoiceGuildMuteEvent
event related to this change.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be muted due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUSER_NOT_CONNECTED
The specified Member is not connected to a voice channel
- Parameters:
member
- TheMember
who'sVoiceState
is being changed.mute
- Whether thisMember
should be muted or unmuted.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.VOICE_DEAF_OTHERS
permission.IllegalArgumentException
- If the provided member is not from this Guild or null.IllegalStateException
- If the provided member is not currently connected to a voice channel.
-
addRoleToMember
@Nonnull @CheckReturnValue AuditableRestAction<Void> addRoleToMember(@Nonnull Member member, @Nonnull Role role)
Atomically assigns the providedRole
to the specifiedMember
.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is already present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Parameters:
member
- The target member who will receive the new rolerole
- The role which should be assigned atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified member/role are not from the current Guild
- Either member or role are
null
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in account
-
addRoleToMember
@Nonnull @CheckReturnValue default AuditableRestAction<Void> addRoleToMember(long userId, @Nonnull Role role)
Atomically assigns the providedRole
to the specified member by their user id.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is already present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Parameters:
userId
- The id of the target member who will receive the new rolerole
- The role which should be assigned atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified role is not from the current Guild
- If the role is
null
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in account
-
addRoleToMember
@Nonnull @CheckReturnValue default AuditableRestAction<Void> addRoleToMember(@Nonnull String userId, @Nonnull Role role)
Atomically assigns the providedRole
to the specified member by their user id.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is already present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Parameters:
userId
- The id of the target member who will receive the new rolerole
- The role which should be assigned atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified role is not from the current Guild
- If the role is
null
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in account
-
removeRoleFromMember
@Nonnull @CheckReturnValue AuditableRestAction<Void> removeRoleFromMember(@Nonnull Member member, @Nonnull Role role)
Atomically removes the providedRole
from the specifiedMember
.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is not present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Parameters:
member
- The target member who will lose the specified rolerole
- The role which should be removed atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified member/role are not from the current Guild
- Either member or role are
null
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in account
-
removeRoleFromMember
@Nonnull @CheckReturnValue default AuditableRestAction<Void> removeRoleFromMember(long userId, @Nonnull Role role)
Atomically removes the providedRole
from the specified member by their user id.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is not present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Parameters:
userId
- The id of the target member who will lose the specified rolerole
- The role which should be removed atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified role is not from the current Guild
- The role is
null
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in account
-
removeRoleFromMember
@Nonnull @CheckReturnValue default AuditableRestAction<Void> removeRoleFromMember(@Nonnull String userId, @Nonnull Role role)
Atomically removes the providedRole
from the specified member by their user id.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is not present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Parameters:
userId
- The id of the target member who will lose the specified rolerole
- The role which should be removed atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified role is not from the current Guild
- The role is
null
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in account
-
modifyMemberRoles
@Nonnull @CheckReturnValue AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nullable Collection<Role> rolesToAdd, @Nullable Collection<Role> rolesToRemove)
Modifies theRoles
of the specifiedMember
by adding and removing a collection of roles.
None of the provided roles may be the Public Role of the current Guild.
If a role is both inrolesToAdd
androlesToRemove
it will be removed.Example
public static void promote(Member member) { Guild guild = member.getGuild(); List<Role> pleb = guild.getRolesByName("Pleb", true); // remove all roles named "pleb" List<Role> knight = guild.getRolesByName("Knight", true); // add all roles named "knight" // update roles in single request guild.modifyMemberRoles(member, knight, pleb).queue(); }
Warning
This may not be used together with any other role add/remove/modify methods for the same Member within one event listener cycle! The changes made by this require cache updates which are triggered by lifecycle events which are received later. This may only be called again once the specific Member has been updated by aGenericGuildMemberEvent
targeting the same Member.This is logically equivalent to:
Set<Role> roles = new HashSet<>(member.getRoles()); roles.addAll(rolesToAdd); roles.removeAll(rolesToRemove); RestAction<Void> action = guild.modifyMemberRoles(member, roles);
You can use
addRoleToMember(Member, Role)
andremoveRoleFromMember(Member, Role)
to make updates independent of the cache.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
- Parameters:
member
- TheMember
that should be modifiedrolesToAdd
- ACollection
ofRoles
to add to the current Roles the specifiedMember
already has, or nullrolesToRemove
- ACollection
ofRoles
to remove from the current Roles the specifiedMember
already has, or null- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountIllegalArgumentException
-- If the target member is
null
- If any of the specified Roles is managed or is the
Public Role
of the Guild
- If the target member is
-
modifyMemberRoles
@Nonnull @CheckReturnValue default AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nonnull Role... roles)
Modifies the completeRole
set of the specifiedMember
The provided roles will replace all current Roles of the specified Member.Warning
This may not be used together with any other role add/remove/modify methods for the same Member within one event listener cycle! The changes made by this require cache updates which are triggered by lifecycle events which are received later. This may only be called again once the specific Member has been updated by aGenericGuildMemberEvent
targeting the same Member.The new roles must not contain the Public Role of the Guild
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
Example
public static void removeRoles(Member member) { Guild guild = member.getGuild(); // pass no role, this means we set the roles of the member to an empty array. guild.modifyMemberRoles(member).queue(); }
- Parameters:
member
- AMember
of which to override the Roles ofroles
- New collection ofRoles
for the specified Member- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountIllegalArgumentException
-- See Also:
modifyMemberRoles(Member, Collection)
-
modifyMemberRoles
@Nonnull @CheckReturnValue AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nonnull Collection<Role> roles)
Modifies the completeRole
set of the specifiedMember
The provided roles will replace all current Roles of the specified Member.The new roles must not contain the Public Role of the Guild
Warning
This may not be used together with any other role add/remove/modify methods for the same Member within one event listener cycle! The changes made by this require cache updates which are triggered by lifecycle events which are received later. This may only be called again once the specific Member has been updated by aGenericGuildMemberEvent
targeting the same Member.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
Example
public static void makeModerator(Member member) { Guild guild = member.getGuild(); List<Role> roles = new ArrayList<>(member.getRoles()); // modifiable copy List<Role> modRoles = guild.getRolesByName("moderator", true); // get roles with name "moderator" roles.addAll(modRoles); // add new roles // update the member with new roles guild.modifyMemberRoles(member, roles).queue(); }
- Parameters:
member
- AMember
of which to override the Roles ofroles
- New collection ofRoles
for the specified Member- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_ROLES
HierarchyException
- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountIllegalArgumentException
-- See Also:
modifyMemberRoles(Member, Collection)
-
transferOwnership
@Nonnull @CheckReturnValue AuditableRestAction<Void> transferOwnership(@Nonnull Member newOwner)
Transfers the Guild ownership to the specifiedMember
Only available if the currently logged in account is the owner of this GuildPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The currently logged in account lost ownership before completing the taskUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
- Parameters:
newOwner
- Not-null Member to transfer ownership to- Returns:
AuditableRestAction
- Throws:
PermissionException
- If the currently logged in account is not the owner of this GuildIllegalArgumentException
-- If the specified Member is
null
or not from the same Guild - If the specified Member already is the Guild owner
- If the specified Member is a bot account (
AccountType.BOT
)
- If the specified Member is
-
createTextChannel
@Nonnull @CheckReturnValue ChannelAction<TextChannel> createTextChannel(@Nonnull String name)
Creates a newTextChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
PermissionPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Parameters:
name
- The name of the TextChannel to create- Returns:
- A specific
ChannelAction
This action allows to set fields for the new TextChannel before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
or empty or greater than 100 characters in length
-
createVoiceChannel
@Nonnull @CheckReturnValue ChannelAction<VoiceChannel> createVoiceChannel(@Nonnull String name)
Creates a newVoiceChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Parameters:
name
- The name of the VoiceChannel to create- Returns:
- A specific
ChannelAction
This action allows to set fields for the new VoiceChannel before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
or empty or greater than 100 characters in length
-
createCategory
@Nonnull @CheckReturnValue ChannelAction<Category> createCategory(@Nonnull String name)
Creates a newCategory
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Parameters:
name
- The name of the Category to create- Returns:
- A specific
ChannelAction
This action allows to set fields for the new Category before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
or empty or greater than 100 characters in length
-
createCopyOfChannel
@Nonnull @CheckReturnValue default <T extends GuildChannel> ChannelAction<T> createCopyOfChannel(@Nonnull T channel)
Creates a copy of the specifiedGuildChannel
in thisGuild
.
The provided channel need not be in the same Guild for this to work!This copies the following elements:
- Name
- Parent Category (if present)
- Voice Elements (Bitrate, Userlimit)
- Text Elements (Topic, NSFW)
- All permission overrides for Members/Roles
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Type Parameters:
T
- The channel type- Parameters:
channel
- TheGuildChannel
to use for the copy template- Returns:
- A specific
ChannelAction
This action allows to set fields for the new GuildChannel before creating it! - Throws:
IllegalArgumentException
- If the provided channel isnull
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_CHANNEL
Permission- Since:
- 3.1
- See Also:
createTextChannel(String)
,createVoiceChannel(String)
,ChannelAction
-
createRole
@Nonnull @CheckReturnValue RoleAction createRole()
Creates a newRole
in this Guild.
It will be placed at the bottom (just over the Public Role) to avoid permission hierarchy conflicts.
For this to be successful, the logged in account has to have theMANAGE_ROLES
PermissionPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The role could not be created due to a permission discrepancyMAX_ROLES_PER_GUILD
There are too many roles in this Guild
- Returns:
RoleAction
Creates a new role with previously selected field values- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_ROLES
Permission
-
createCopyOfRole
@Nonnull @CheckReturnValue default RoleAction createCopyOfRole(@Nonnull Role role)
Creates a newRole
in thisGuild
with the same settings as the givenRole
.
The position of the specified Role does not matter in this case!It will be placed at the bottom (just over the Public Role) to avoid permission hierarchy conflicts.
For this to be successful, the logged in account has to have theMANAGE_ROLES
Permission and allPermissions
the givenRole
has.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The role could not be created due to a permission discrepancyMAX_ROLES_PER_GUILD
There are too many roles in this Guild
- Parameters:
role
- TheRole
that should be copied- Returns:
RoleAction
RoleAction with already copied values from the specifiedRole
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_ROLES
Permission and every Permission the provided Role hasIllegalArgumentException
- If the specified role isnull
-
createEmote
@Nonnull @CheckReturnValue AuditableRestAction<Emote> createEmote(@Nonnull String name, @Nonnull Icon icon, @Nonnull Role... roles)
Creates a newEmote
in this Guild.
If one or more Roles are specified the new Emote will only be available to Members with any of the specified Roles (seeMember.canInteract(Emote)
)
For this to be successful, the logged in account has to have theMANAGE_EMOTES
Permission.Unicode emojis are not included as
Emote
!Note that a guild is limited to 50 normal and 50 animated emotes by default. Some guilds are able to add additional emotes beyond this limitation due to the
MORE_EMOJI
feature (seeGuild.getFeatures()
).
Due to simplicity we do not check for these limits.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The emote could not be created due to a permission discrepancy
- Parameters:
name
- The name for the new Emoteicon
- TheIcon
for the new Emoteroles
- TheRoles
the new Emote should be restricted to
If no roles are provided the Emote will be available to all Members of this Guild- Returns:
AuditableRestAction
- Type:Emote
- Throws:
InsufficientPermissionException
- If the logged in account does not have theMANAGE_EMOTES
Permission
-
modifyCategoryPositions
@Nonnull @CheckReturnValue ChannelOrderAction modifyCategoryPositions()
Modifies the positional order ofGuild.getCategories()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Returns:
ChannelOrderAction
- Type:Category
-
modifyTextChannelPositions
@Nonnull @CheckReturnValue ChannelOrderAction modifyTextChannelPositions()
Modifies the positional order ofGuild.getTextChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Returns:
ChannelOrderAction
- Type:TextChannel
-
modifyVoiceChannelPositions
@Nonnull @CheckReturnValue ChannelOrderAction modifyVoiceChannelPositions()
Modifies the positional order ofGuild.getVoiceChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Returns:
ChannelOrderAction
- Type:VoiceChannel
-
modifyTextChannelPositions
@Nonnull @CheckReturnValue CategoryOrderAction modifyTextChannelPositions(@Nonnull Category category)
Modifies the positional order ofCategory#getTextChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedTextChannels
of thisCategory
.
LikeChannelOrderAction
, the returnedCategoryOrderAction
can be used to move TextChannelsup
,down
, orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the task.MISSING_ACCESS
The currently logged in account was removed from the Guild.
- Parameters:
category
- TheCategory
to orderTextChannels
from.- Returns:
CategoryOrderAction
- Type:TextChannel
-
modifyVoiceChannelPositions
@Nonnull @CheckReturnValue CategoryOrderAction modifyVoiceChannelPositions(@Nonnull Category category)
Modifies the positional order ofCategory#getVoiceChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedVoiceChannels
of thisCategory
.
LikeChannelOrderAction
, the returnedCategoryOrderAction
can be used to move VoiceChannelsup
,down
, orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the task.MISSING_ACCESS
The currently logged in account was removed from the Guild.
- Parameters:
category
- TheCategory
to orderVoiceChannels
from.- Returns:
CategoryOrderAction
- Type:VoiceChannels
-
modifyRolePositions
@Nonnull @CheckReturnValue default RoleOrderAction modifyRolePositions()
Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.This uses ascending ordering which means the lowest role is first!
This means the highest role appears at indexn - 1
and the lower role at index0
.
Providingtrue
tomodifyRolePositions(boolean)
will result in the ordering being in ascending order, with the lower role at indexn - 1
and the highest at index0
.
As a note:Member.getRoles()
andGuild.getRoles()
are both in descending order.Possible
ErrorResponses
include:UNKNOWN_ROLE
One of the roles was deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Returns:
RoleOrderAction
-
modifyRolePositions
@Nonnull @CheckReturnValue RoleOrderAction modifyRolePositions(boolean useAscendingOrder)
Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.Possible
ErrorResponses
include:UNKNOWN_ROLE
One of the roles was deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Parameters:
useAscendingOrder
- Defines the ordering of the OrderAction. Iffalse
, the OrderAction will be in the ordering defined by Discord for roles, which is Descending. This means that the highest role appears at index0
and the lowest role at indexn - 1
. Providingtrue
will result in the ordering being in ascending order, with the lower role at index0
and the highest at indexn - 1
.
As a note:Member.getRoles()
andGuild.getRoles()
are both in descending order.- Returns:
RoleOrderAction
-
-