Interface Guild
- All Superinterfaces:
ISnowflake
Guild
.
This should contain all information provided from Discord about a Guild.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Represents a Ban object.static enum
The boost tier for this guild.static enum
The Explicit-Content-Filter Level of a Guild.static class
Meta-Data for a Guildstatic enum
Represents the Multifactor Authentication level required by the Guild.static enum
Represents the Notification-level of the Guild.static enum
Represents the NSFW level for this guild.static enum
Represents the idle time allowed until a user is moved to the AFKVoiceChannel
if one is set (Guild.getAfkChannel()
).static enum
Represents the Verification-Level of the Guild. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Template forgetBannerUrl()
.static final String
Template forgetIconUrl()
.static final String
Template forgetSplashUrl()
. -
Method Summary
Modifier and TypeMethodDescriptiondefault MemberAction
Adds the user represented by the provided id to this guild.Adds the user represented by the provided id to this guild.default MemberAction
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.addRoleToMember
(Member member, Role role) default AuditableRestAction<Void>
Bans the user specified by the userId and deletes messages sent by the user based on the amount of delDays.Bans the user specified by the userId and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
Bans theMember
and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
Bans theMember
and deletes messages sent by the user based on the amount of delDays.default AuditableRestAction<Void>
Bans theMember
and deletes messages sent by the user based on the amount of delDays.Bans theUser
and deletes messages sent by the user based on the amount of delDays.Cancels theRequest-to-Speak
.createCategory
(String name) Creates a newCategory
in this Guild.default <T extends ICopyableChannel>
ChannelAction<T>createCopyOfChannel
(T channel) Creates a copy of the specifiedGuildChannel
in thisGuild
.default RoleAction
createCopyOfRole
(Role role) createEmote
(String name, Icon icon, Role... roles) Creates a newEmote
in this Guild.default ChannelAction<NewsChannel>
createNewsChannel
(String name) Creates a newNewsChannel
in this Guild.createNewsChannel
(String name, Category parent) Creates a newNewsChannel
in this Guild.Creates a newRole
in this Guild.default ChannelAction<StageChannel>
createStageChannel
(String name) Creates a newStageChannel
in this Guild.createStageChannel
(String name, Category parent) Creates a newStageChannel
in this Guild.createTemplate
(String name, String description) Used to create a newTemplate
for this Guild.default ChannelAction<TextChannel>
createTextChannel
(String name) Creates a newTextChannel
in this Guild.createTextChannel
(String name, Category parent) Creates a newTextChannel
in this Guild.default ChannelAction<VoiceChannel>
createVoiceChannel
(String name) Creates a newVoiceChannel
in this Guild.createVoiceChannel
(String name, Category parent) Creates a newVoiceChannel
in this Guild.Sets the Guild Deafened state state of theMember
based on the provided boolean.delete()
Used to completely delete a Guild.Used to completely delete a guild.default RestAction<Void>
deleteCommandById
(long commandId) Delete the command for this id.deleteCommandById
(String commandId) Delete the command for this id.default CommandEditAction
editCommandById
(long id) Edit an existing command by id.Edit an existing command by id.findMembers
(Predicate<? super Member> filter) Retrieves and collects members of this guild into a list.findMembersWithRoles
(Collection<Role> roles) Retrieves and collects members of this guild into a list.findMembersWithRoles
(Role... roles) Retrieves and collects members of this guild into a list.Provides theVoiceChannel
that has been set as the channel whichMembers
will be moved to after they have been inactive in aVoiceChannel
for longer thangetAfkTimeout()
.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.TheAudioManager
that represents the audio connection for this Guild.The guild banner id.default String
The guild banner url.int
The amount of boosts this server currently has.Sorted list ofMembers
that boost this guild.default Role
Looks up the role which is the booster role of this guild.The boost tier for this guild.default Role
Looks up the role which is the integration role for the currently connected bot (self-user).Gets allCategories
in thisGuild
.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
Gets theCategory
from this guild that matches the provided id.SortedSnowflakeCacheView
of all cachedCategories
of this Guild.default List<GuildChannel>
Populated list ofchannels
for this guild.getChannels
(boolean includeHidden) Populated list ofchannels
for this guild.Provides theTextChannel
that receives community updates.The defaultTextChannel
for aGuild
.Returns the default message Notification-Level of this Guild.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
of all cachedEmotes
of this Guild.getEmotesByName
(String name, boolean ignoreCase) Gets a list of allEmotes
in this Guild that have the same name as the one provided.The level of content filtering enabled in this Guild.The Features of theGuild
.default GuildChannel
getGuildChannelById
(long id) GetGuildChannel
for the provided ID.default GuildChannel
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.The Discord hash-id of theGuild
icon image.default String
The URL of theGuild
icon image.getJDA()
Returns theJDA
instance of this GuildThe preferred locale for this guild.Returns theGuildManager
for this Guild, used to modify all properties and settings of the Guild.default int
The maximum bitrate that can be applied to a voice channel in this guild.default int
The maximum amount of emotes a guild can have based on the guilds boost tier.default long
Returns the maximum size for files that can be uploaded to this Guild.int
The maximum amount of members that can join this guild.int
The maximum amount of connected members this guild can have at a time.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
for all cachedMembers
of this Guild.int
The expected member count for this guild.A list of allMembers
in this Guild.getMembersByEffectiveName
(String name, boolean ignoreCase) Gets a list of allMembers
who have the same effective name as the one provided.getMembersByName
(String name, boolean ignoreCase) Gets a list of allMembers
who have the same name as the one provided.getMembersByNickname
(String nickname, boolean ignoreCase) Gets a list of allMembers
who have the same nickname as the one provided.getMembersWithRoles
(Collection<Role> roles) getMembersWithRoles
(Role... roles) getName()
The human readable name of theGuild
.default NewsChannel
getNewsChannelById
(long id) Gets aNewsChannel
from this guild that has the same id as the one provided.default NewsChannel
Gets aNewsChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedNewsChannels
of this Guild.default List<NewsChannel>
Gets allNewsChannels
in thisGuild
.default List<NewsChannel>
getNewsChannelsByName
(String name, boolean ignoreCase) Gets a list of allNewsChannels
in this Guild that have the same name as the one provided.Returns the NSFW Level that this guild is classified with.getOwner()
TheMember
object for the owner of this Guild.default String
The ID for the current owner of this guild.long
The ID for the current owner of this guild.Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.default Role
getRoleByBot
(long userId) Looks up a role which is the integration role for a bot.default Role
getRoleByBot
(String userId) Looks up a role which is the integration role for a bot.default Role
getRoleByBot
(User user) Looks up a role which is the integration role for a bot.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
of all cachedRoles
of this Guild.getRoles()
getRolesByName
(String name, boolean ignoreCase) Gets a list of allRoles
in this Guild that have the same name as the one provided.Provides theTextChannel
that lists the rules of the guild.Gets theMember
object of the currently logged in account in this guild.The Discord hash-id of the splash image for this Guild.default String
The URL of the splash image for this Guild.default StageChannel
getStageChannelById
(long id) Gets aStageChannel
from this guild that has the same id as the one provided.default StageChannel
Gets aStageChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedStageChannel
of this Guild.default List<StageChannel>
Gets allStageChannel
in thisGuild
.default List<StageChannel>
getStageChannelsByName
(String name, boolean ignoreCase) Gets a list of allStageChannel
in this Guild that have the same name as the one provided.default StoreChannel
getStoreChannelById
(long id) Gets aStoreChannel
from this guild that has the same id as the one provided.default StoreChannel
Gets aStoreChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedStoreChannels
of this Guild.default List<StoreChannel>
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.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
Gets aTextChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedTextChannels
of this Guild.default List<TextChannel>
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.default ThreadChannel
getThreadChannelById
(long id) Gets aThreadChannel
from this guild that has the same id as the one provided.default ThreadChannel
Gets aThreadChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedThreadChannel
of this Guild.default List<ThreadChannel>
Gets allThreadChannel
in thisGuild
.default List<ThreadChannel>
getThreadChannelsByName
(String name, boolean ignoreCase) Gets a list of allThreadChannel
in this Guild that have the same name as the one provided.The vanity url code for this Guild.default String
The vanity url for this Guild.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
Gets aVoiceChannel
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedVoiceChannels
of this Guild.default List<VoiceChannel>
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.boolean
Returns whether this Guild has its boost progress bar shown.boolean
isLoaded()
Whether this guild has loaded members.boolean
Used to determine if the providedUser
is a member of this Guild.default AuditableRestAction<Void>
default AuditableRestAction<Void>
default RestAction<Void>
kickVoiceMember
(Member member) Used to kick aMember
from aAudioChannel
.leave()
Used to leave a Guild.Retrieves and collects members of this guild into a list.loadMembers
(Consumer<Member> callback) Retrieves all members of this guild.Modifies the positional order ofGuild.getCategories()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.modifyMemberRoles
(Member member, Collection<Role> roles) modifyMemberRoles
(Member member, Collection<Role> rolesToAdd, Collection<Role> rolesToRemove) default AuditableRestAction<Void>
modifyMemberRoles
(Member member, Role... roles) modifyNickname
(Member member, String nickname) Changes the Member's nickname in this guild.default RoleOrderAction
Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.modifyRolePositions
(boolean useAscendingOrder) Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.Modifies the positional order ofGuild.getTextChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.modifyTextChannelPositions
(Category category) Modifies the positional order ofCategory#getTextChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedTextChannels
of thisCategory
.Modifies the positional order ofGuild.getVoiceChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.modifyVoiceChannelPositions
(Category category) Modifies the positional order ofCategory#getVoiceChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedVoiceChannels
of thisCategory
.moveVoiceMember
(Member member, AudioChannel audioChannel) Sets the Guild Muted state state of theMember
based on the provided boolean.This method will prune (kick) all members who were offline for at least days days.default AuditableRestAction<Integer>
This method will prune (kick) all members who were offline for at least days days.void
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.removeRoleFromMember
(Member member, Role role) default AuditableRestAction<Void>
removeTimeout
(Member member) Removes a time out from the specified Member in thisGuild
.default AuditableRestAction<Void>
removeTimeoutById
(long userId) Removes a time out from a Member specified by the id in thisGuild
.removeTimeoutById
(String userId) Removes a time out from a Member specified by the id in thisGuild
.Once the currently logged in account is connected to aStageChannel
, this will trigger aRequest-to-Speak
(aka raise your hand).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(id, int)
orunban(id)
.retrieveBanById
(String userId) Retrieves aBan
of the provided ID
If you wish to ban or unban a user, use eitherban(id, int)
orunban(id)
.Retrieves an immutable list of the currently bannedUsers
.default RestAction<Command>
retrieveCommandById
(long id) Retrieves the existingCommand
instance by id.Retrieves the existingCommand
instance by id.Retrieves theCommandPrivileges
for the commands in this guild.default RestAction<List<CommandPrivilege>>
retrieveCommandPrivilegesById
(long commandId) Retrieves theCommandPrivileges
for the command with the specified ID.retrieveCommandPrivilegesById
(String commandId) Retrieves theCommandPrivileges
for the command with the specified ID.Retrieves the list of guild commands.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.Retrieves a listed emote together with its respective creator.Retrieves an immutable list of emotes together with their respective creators.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.retrieveMemberById
(long id, boolean update) Load the member for the specified user.default RestAction<Member>
Load the member for the specified user.default RestAction<Member>
retrieveMemberById
(String id, boolean update) Load the member for the specified user.retrieveMembers
(boolean includePresence, Collection<User> users) Retrieves a list of members.retrieveMembers
(Collection<User> users) Retrieves a list of members.retrieveMembersByIds
(boolean includePresence, long... ids) Retrieves a list of members by their user id.retrieveMembersByIds
(boolean includePresence, String... ids) Retrieves a list of members by their user id.retrieveMembersByIds
(boolean includePresence, Collection<Long> ids) Retrieves a list of members by their user id.retrieveMembersByIds
(long... ids) Retrieves a list of members by their user id.retrieveMembersByIds
(String... ids) Retrieves a list of members by their user id.Retrieves a list of members by their user id.retrieveMembersByPrefix
(String prefix, int limit) Queries a list of members using a radix tree based on the provided name prefix.LoadsGuild.MetaData
for this guild instance.default RestAction<Member>
Shortcut forguild.retrieveMemberById(guild.getOwnerIdLong())
.default RestAction<Member>
retrieveOwner
(boolean update) Shortcut forguild.retrieveMemberById(guild.getOwnerIdLong())
.retrievePrunableMemberCount
(int days) The method calculates the amount of Members that would be pruned ifprune(int, Role...)
was executed.default RestAction<EnumSet<Region>>
Retrieves the available regions for this Guild
Shortcut forretrieveRegions(true)
This will include deprecated voice regions by default.retrieveRegions
(boolean includeDeprecated) Retrieves the available regions for this GuildRetrieves allTemplates
for this guild.Retrieves the Vanity Invite meta data for this guild.Retrieves allWebhooks
for this Guild.default AuditableRestAction<Void>
timeoutFor
(Member member, long amount, TimeUnit unit) Puts the specified Member in time out in thisGuild
for a specific amount of time.default AuditableRestAction<Void>
timeoutFor
(Member member, Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.default AuditableRestAction<Void>
timeoutForById
(long userId, long amount, TimeUnit unit) Puts a Member specified by the id in time out in thisGuild
for a specific amount of time.default AuditableRestAction<Void>
timeoutForById
(long userId, Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.default AuditableRestAction<Void>
timeoutForById
(String userId, long amount, TimeUnit unit) Puts a Member specified by the id in time out in thisGuild
for a specific amount of time.default AuditableRestAction<Void>
timeoutForById
(String userId, Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.default AuditableRestAction<Void>
timeoutUntil
(Member member, TemporalAccessor temporal) Puts the specified Member in time out in thisGuild
until the specified date.default AuditableRestAction<Void>
timeoutUntilById
(long userId, TemporalAccessor temporal) Puts a Member specified by the id in time out in thisGuild
until the specified date.timeoutUntilById
(String userId, TemporalAccessor temporal) Puts a Member specified by the id in time out in thisGuild
until the specified date.transferOwnership
(Member newOwner) Transfers the Guild ownership to the specifiedMember
Only available if the currently logged in account is the owner of this GuildUnbans the a user specified by the userId from this Guild.default AuditableRestAction<Void>
Unbans the specifiedUser
from this Guild.boolean
unloadMember
(long userId) Attempts to remove the user with the provided id from the member cache.updateCommandPrivileges
(Map<String, ? extends Collection<CommandPrivilege>> privileges) Updates the list ofCommandPrivileges
for the specified commands.default RestAction<List<CommandPrivilege>>
updateCommandPrivilegesById
(long id, Collection<? extends CommandPrivilege> privileges) Updates the list ofCommandPrivileges
for the specified command.default RestAction<List<CommandPrivilege>>
updateCommandPrivilegesById
(long id, CommandPrivilege... privileges) Updates the list ofCommandPrivileges
for the specified command.updateCommandPrivilegesById
(String id, Collection<? extends CommandPrivilege> privileges) Updates the list ofCommandPrivileges
for the specified command.default RestAction<List<CommandPrivilege>>
updateCommandPrivilegesById
(String id, CommandPrivilege... privileges) Updates the list ofCommandPrivileges
for the specified command.Configures the complete list of guild commands.default CommandCreateAction
upsertCommand
(String name, String description) Creates or updates a slash command.upsertCommand
(CommandData command) Creates or updates a command.Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
Field Details
-
ICON_URL
Template forgetIconUrl()
.- See Also:
-
SPLASH_URL
Template forgetSplashUrl()
.- See Also:
-
BANNER_URL
Template forgetBannerUrl()
.- See Also:
-
-
Method Details
-
retrieveCommands
Retrieves the list of guild commands.
This list does not include global commands! UseJDA.retrieveCommands()
for global commands.- Returns:
RestAction
- Type:List
ofCommand
-
retrieveCommandById
Retrieves the existingCommand
instance by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The command id- Returns:
RestAction
- Type:Command
- Throws:
IllegalArgumentException
- If the provided id is not a valid snowflake
-
retrieveCommandById
Retrieves the existingCommand
instance by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The command id- Returns:
RestAction
- Type:Command
-
upsertCommand
Creates or updates a command.
If a command with the same name exists, it will be replaced. This operation is idempotent. Commands will persist between restarts of your bot, you only have to create a command once.To specify a complete list of all commands you can use
updateCommands()
instead.You need the OAuth2 scope
"applications.commands"
in order to add commands to a guild.- Parameters:
command
- TheCommandData
for the command- Returns:
RestAction
- Type:Command
The RestAction used to create or update the command- Throws:
IllegalArgumentException
- If null is provided- See Also:
-
upsertCommand
@Nonnull @CheckReturnValue default CommandCreateAction upsertCommand(@Nonnull String name, @Nonnull String description) Creates or updates a slash command.
If a command with the same name exists, it will be replaced. This operation is idempotent. Commands will persist between restarts of your bot, you only have to create a command once.To specify a complete list of all commands you can use
updateCommands()
instead.You need the OAuth2 scope
"applications.commands"
in order to add commands to a guild.- Parameters:
name
- The lowercase alphanumeric (with dash) name, 1-32 charactersdescription
- The description for the command, 1-100 characters- Returns:
CommandCreateAction
- Throws:
IllegalArgumentException
- If null is provided or the name/description do not meet the requirements
-
updateCommands
Configures the complete list of guild commands.
This will replace the existing command list for this guild. You should only use this at most once on startup!This operation is idempotent. Commands will persist between restarts of your bot, you only have to create a command once.
You need the OAuth2 scope
"applications.commands"
in order to add commands to a guild.Examples
// Set list to 2 commands guild.updateCommands() .addCommands(Commands.slash("ping", "Gives the current ping")) .addCommands(Commands.slash("ban", "Ban the target user") .addOption(OptionType.USER, "user", "The user to ban", true)) .queue(); // Delete all commands guild.updateCommands().queue();
- Returns:
CommandListUpdateAction
- See Also:
-
editCommandById
Edit an existing command by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The id of the command to edit- Returns:
CommandEditAction
used to edit the command- Throws:
IllegalArgumentException
- If the provided id is not a valid snowflake
-
editCommandById
Edit an existing command by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The id of the command to edit- Returns:
CommandEditAction
used to edit the command
-
deleteCommandById
Delete the command for this id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
commandId
- The id of the command that should be deleted- Returns:
RestAction
- Throws:
IllegalArgumentException
- If the provided id is not a valid snowflake
-
deleteCommandById
Delete the command for this id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
commandId
- The id of the command that should be deleted- Returns:
RestAction
-
retrieveCommandPrivilegesById
@Nonnull @CheckReturnValue RestAction<List<CommandPrivilege>> retrieveCommandPrivilegesById(@Nonnull String commandId) Retrieves theCommandPrivileges
for the command with the specified ID.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
commandId
- The id of the command, this can be global or guild command- Returns:
RestAction
- Type:List
ofCommandPrivilege
- Throws:
IllegalArgumentException
- If the id is not a valid snowflake
-
retrieveCommandPrivilegesById
@Nonnull @CheckReturnValue default RestAction<List<CommandPrivilege>> retrieveCommandPrivilegesById(long commandId) Retrieves theCommandPrivileges
for the command with the specified ID.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
commandId
- The id of the command, this can be global or guild command- Returns:
RestAction
- Type:List
ofCommandPrivilege
- Throws:
IllegalArgumentException
- If the id is not a valid snowflake
-
retrieveCommandPrivileges
@Nonnull @CheckReturnValue RestAction<Map<String,List<CommandPrivilege>>> retrieveCommandPrivileges()Retrieves theCommandPrivileges
for the commands in this guild.
The RestAction provides aMap
from the command id to the list of privileges.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
- Returns:
RestAction
- Type:Map
fromString
Command ID toList
ofCommandPrivilege
-
updateCommandPrivilegesById
@Nonnull @CheckReturnValue RestAction<List<CommandPrivilege>> updateCommandPrivilegesById(@Nonnull String id, @Nonnull Collection<? extends CommandPrivilege> privileges) Updates the list ofCommandPrivileges
for the specified command.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)
on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The id of the command, this can be global or guild commandprivileges
- Complete list of up to 10CommandPrivileges
for this command- Returns:
RestAction
- Type:List
orCommandPrivilege
The updated list of privileges for this command.- Throws:
IllegalArgumentException
- If null is provided, the id is not a valid snowflake, or more than 10 privileges are provided
-
updateCommandPrivilegesById
@Nonnull @CheckReturnValue default RestAction<List<CommandPrivilege>> updateCommandPrivilegesById(@Nonnull String id, @Nonnull CommandPrivilege... privileges) Updates the list ofCommandPrivileges
for the specified command.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)
on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The id of the command, this can be global or guild commandprivileges
- Complete list of up to 10CommandPrivileges
for this command- Returns:
RestAction
- Type:List
orCommandPrivilege
The updated list of privileges for this command.- Throws:
IllegalArgumentException
- If null is provided, the id is not a valid snowflake, or more than 10 privileges are provided
-
updateCommandPrivilegesById
@Nonnull @CheckReturnValue default RestAction<List<CommandPrivilege>> updateCommandPrivilegesById(long id, @Nonnull Collection<? extends CommandPrivilege> privileges) Updates the list ofCommandPrivileges
for the specified command.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)
on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The id of the command, this can be global or guild commandprivileges
- Complete list of up to 10CommandPrivileges
for this command- Returns:
RestAction
- Type:List
orCommandPrivilege
The updated list of privileges for this command.- Throws:
IllegalArgumentException
- If null is provided or more than 10 privileges are provided
-
updateCommandPrivilegesById
@Nonnull @CheckReturnValue default RestAction<List<CommandPrivilege>> updateCommandPrivilegesById(long id, @Nonnull CommandPrivilege... privileges) Updates the list ofCommandPrivileges
for the specified command.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)
on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
id
- The id of the command, this can be global or guild commandprivileges
- Complete list of up to 10CommandPrivileges
for this command- Returns:
RestAction
- Type:List
orCommandPrivilege
The updated list of privileges for this command.- Throws:
IllegalArgumentException
- If null is provided or more than 10 privileges are provided
-
updateCommandPrivileges
@Nonnull @CheckReturnValue RestAction<Map<String,List<CommandPrivilege>>> updateCommandPrivileges(@Nonnull Map<String, ? extends Collection<CommandPrivilege>> privileges) Updates the list ofCommandPrivileges
for the specified commands.
The argument for this function is aMap
similar to the one returned byretrieveCommandPrivileges()
.
Note that commands are enabled by default for all members of a guild, which means you can only blacklist roles and members using this method. To change this behavior, useCommandData.setDefaultEnabled(boolean)
on your command.These privileges are used to restrict who can use commands through Role/User whitelists/blacklists.
If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
privileges
- Complete map ofCommandPrivileges
for each command- Returns:
RestAction
- Type:Map
fromString
Command ID toList
ofCommandPrivilege
The updated map of command privileges for this guild.- Throws:
IllegalArgumentException
- If null is provided, any of the map keys is not a valid snowflake, or more than 10 privileges are provided for any command
-
retrieveRegions
Retrieves the available regions for this Guild
Shortcut forretrieveRegions(true)
This will include deprecated voice regions by default.- Returns:
RestAction
- TypeEnumSet
-
retrieveRegions
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:
-
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:
-
addMember
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:
-
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
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:
-
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
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
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
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
The Features of theGuild
.- Returns:
- Never-null, unmodifiable Set containing all of the Guild's features.
-
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
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.
-
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.- Returns:
- The vanity code or null
- Since:
- 4.0.0
- See Also:
-
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.- Returns:
- The vanity url or null
- Since:
- 4.0.0
-
retrieveVanityInvite
Retrieves the Vanity Invite meta data for this guild.
This allows you to inspect how many times the vanity invite has been used. You can usegetVanityUrl()
if you only care about the invite.This action requires the
MANAGE_SERVER
permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:INVITE_CODE_INVALID
If this guild does not have a vanity inviteMISSING_PERMISSIONS
The vanity invite cannot be fetched due to a permission discrepancy
- Returns:
RestAction
- Type:VanityInvite
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_SERVER
- Since:
- 4.2.1
-
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
The preferred locale for this guild.
If the guild doesn't have the COMMUNITY feature, this returns the default.
Default:Locale.US
- Returns:
- The preferred
Locale
for this guild - Since:
- 4.2.1
-
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
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
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
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:
-
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
LoadsGuild.MetaData
for this guild instance.- Returns:
RestAction
- Type:Guild.MetaData
- Since:
- 4.2.0
-
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
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.
-
getRulesChannel
Provides theTextChannel
that lists the rules of the guild.
If this guild doesn't have the COMMUNITYfeature
, this returnsnull
.- Returns:
- Possibly-null
TextChannel
that is the rules channel - See Also:
-
getCommunityUpdatesChannel
Provides theTextChannel
that receives community updates.
If this guild doesn't have the COMMUNITYfeature
, this returnsnull
.- Returns:
- Possibly-null
TextChannel
that is the community updates channel - See Also:
-
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
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:
-
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:
-
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.
-
isMember
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
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.
-
getNSFWLevel
Returns the NSFW Level that this guild is classified with.
For a short description of the different values, seeNSFWLevel
.This value can only be modified by Discord after reviewing the Guild.
- Returns:
- The NSFWLevel of this guild.
-
getMember
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:
-
getMemberById
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:
-
getMemberById
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:
-
getMemberByTag
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:
-
getMemberByTag
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:
-
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:
-
getMembersByName
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:
-
getMembersByNickname
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:
-
getMembersByEffectiveName
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:
-
getMembersWithRoles
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.- See Also:
-
getMembersWithRoles
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.- See Also:
-
getMemberCache
MemberCacheView
for all cachedMembers
of this Guild.This will only provide cached members!
SeeMemberCachePolicy
- Returns:
MemberCacheView
- See Also:
-
getGuildChannelById
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
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
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
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
-
getStageChannelCache
SortedSnowflakeCacheView
of all cachedStageChannel
of this Guild.
StageChannel are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getStageChannelsByName
@Nonnull default List<StageChannel> getStageChannelsByName(@Nonnull String name, boolean ignoreCase) Gets a list of allStageChannel
in this Guild that have the same name as the one provided.
If there are noStageChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedStageChannels
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all StageChannel names that match the provided name.
-
getStageChannelById
Gets aStageChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getStageChannelById(String)
, but it only checks this specific Guild for a StageChannel.
If there is noStageChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theStageChannel
.- Returns:
- Possibly-null
StageChannel
with matching id. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getStageChannelById
Gets aStageChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getStageChannelById(long)
, but it only checks this specific Guild for a StageChannel.
If there is noStageChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theStageChannel
.- Returns:
- Possibly-null
StageChannel
with matching id.
-
getStageChannels
Gets allStageChannel
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
getStageChannelCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of
StageChannels
.
-
getThreadChannelCache
SortedSnowflakeCacheView
of all cachedThreadChannel
of this Guild.
StageChannel are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getThreadChannelsByName
@Nonnull default List<ThreadChannel> getThreadChannelsByName(@Nonnull String name, boolean ignoreCase) Gets a list of allThreadChannel
in this Guild that have the same name as the one provided.
If there are noThreadChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedThreadChannels
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all ThreadChannel names that match the provided name.
-
getThreadChannelById
Gets aThreadChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getThreadChannelById(String)
, but it only checks this specific Guild for a ThreadChannel.
If there is noThreadChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theThreadChannel
.- Returns:
- Possibly-null
ThreadChannel
with matching id. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getThreadChannelById
Gets aThreadChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getThreadChannelById(long)
, but it only checks this specific Guild for a ThreadChannel.
If there is noThreadChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theThreadChannel
.- Returns:
- Possibly-null
ThreadChannel
with matching id.
-
getThreadChannels
Gets allThreadChannel
in thisGuild
.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
getThreadChannelCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of
ThreadChannels
.
-
getCategoryById
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
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
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
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
SortedSnowflakeCacheView
of all cachedCategories
of this Guild.
Categories are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getStoreChannelById
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
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
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
SortedSnowflakeCacheView
of all cachedStoreChannels
of this Guild.
TextChannels are sorted according to their position.- Returns:
SortedSnowflakeCacheView
- Since:
- 4.0.0
-
getTextChannelById
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
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
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
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
SortedSnowflakeCacheView
of all cachedTextChannels
of this Guild.
TextChannels are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getNewsChannelById
Gets aNewsChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getNewsChannelById(String)
, but it only checks this specific Guild for a NewsChannel.
If there is noNewsChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theNewsChannel
.- Returns:
- Possibly-null
NewsChannel
with matching id. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getNewsChannelById
Gets aNewsChannel
from this guild that has the same id as the one provided. This method is similar toJDA.getNewsChannelById(long)
, but it only checks this specific Guild for a NewsChannel.
If there is noNewsChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theNewsChannel
.- Returns:
- Possibly-null
NewsChannel
with matching id.
-
getNewsChannels
Gets allNewsChannels
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
getNewsChannelCache()
and use its more efficient versions of handling these values.- Returns:
- An immutable List of all
NewsChannels
in this Guild.
-
getNewsChannelsByName
Gets a list of allNewsChannels
in this Guild that have the same name as the one provided.
If there are noNewsChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name used to filter the returnedNewsChannels
.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all NewsChannels names that match the provided name.
-
getNewsChannelCache
SortedSnowflakeCacheView
of all cachedNewsChannels
of this Guild.
NewsChannel are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getVoiceChannelById
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
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
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
SortedSnowflakeCacheView
of all cachedVoiceChannels
of this Guild.
VoiceChannels are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
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
- StageChannel without parent
- Categories
- TextChannel and StoreChannel with category as parent
- VoiceChannel with category as parent
- StageChannel with category as parent
- Returns:
- Immutable list of channels for this guild
- See Also:
-
getChannels
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
- StageChannel without parent
- Categories
- TextChannel and StoreChannel with category as parent
- VoiceChannel with category as parent
- StageChannel with category as parent
- Parameters:
includeHidden
- Whether to include channels with deniedView Channel Permission
- Returns:
- Immutable list of channels for this guild
- See Also:
-
getRoleById
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)
-
getRoleById
-
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
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.
-
getRoleByBot
Looks up a role which is the integration role for a bot.
These roles are created when the bot requested a list of permission in the authorization URL.To check whether a role is a bot role you can use
role.getTags().isBot()
and you can useRole.RoleTags.getBotIdLong()
to check which bot it applies to.This requires
CacheFlag.ROLE_TAGS
to be enabled. SeeJDABuilder.enableCache(...)
.- Parameters:
userId
- The user id of the bot- Returns:
- The bot role, or null if no role matches
-
getRoleByBot
Looks up a role which is the integration role for a bot.
These roles are created when the bot requested a list of permission in the authorization URL.To check whether a role is a bot role you can use
role.getTags().isBot()
and you can useRole.RoleTags.getBotIdLong()
to check which bot it applies to.This requires
CacheFlag.ROLE_TAGS
to be enabled. SeeJDABuilder.enableCache(...)
.- Parameters:
userId
- The user id of the bot- Returns:
- The bot role, or null if no role matches
- Throws:
IllegalArgumentException
- If the userId is null or not a valid snowflake
-
getRoleByBot
Looks up a role which is the integration role for a bot.
These roles are created when the bot requested a list of permission in the authorization URL.To check whether a role is a bot role you can use
role.getTags().isBot()
and you can useRole.RoleTags.getBotIdLong()
to check which bot it applies to.This requires
CacheFlag.ROLE_TAGS
to be enabled. SeeJDABuilder.enableCache(...)
.- Parameters:
user
- The bot user- Returns:
- The bot role, or null if no role matches
- Throws:
IllegalArgumentException
- If null is provided
-
getBotRole
Looks up the role which is the integration role for the currently connected bot (self-user).
These roles are created when the bot requested a list of permission in the authorization URL.To check whether a role is a bot role you can use
role.getTags().isBot()
and you can useRole.RoleTags.getBotIdLong()
to check which bot it applies to.This requires
CacheFlag.ROLE_TAGS
to be enabled. SeeJDABuilder.enableCache(...)
.- Returns:
- The bot role, or null if no role matches
-
getBoostRole
Looks up the role which is the booster role of this guild.
These roles are created when the first user boosts this guild.To check whether a role is a booster role you can use
role.getTags().isBoost()
.This requires
CacheFlag.ROLE_TAGS
to be enabled. SeeJDABuilder.enableCache(...)
.- Returns:
- The boost role, or null if no role matches
-
getRoleCache
SortedSnowflakeCacheView
of all cachedRoles
of this Guild.
Roles are sorted according to their position.- Returns:
SortedSnowflakeCacheView
-
getEmoteById
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:
-
getEmoteById
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:
-
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:
-
getEmotesByName
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
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
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_AND_STICKERS
.- Returns:
RestAction
- Type: List ofListedEmote
- Since:
- 3.8.0
-
retrieveEmoteById
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_AND_STICKERS
.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
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_AND_STICKERS
.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
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_AND_STICKERS
.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
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
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.
-
retrieveBanById
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
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
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
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
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.VIEW_CHANNEL
in.- Returns:
- The
TextChannel
representing the default channel for this guild
-
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()
.This is a lazy idempotent getter. The manager is retained after the first call. This getter is not thread-safe and would require guards by the user.
- Returns:
- The Manager of this Guild
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_SERVER
-
isBoostProgressBarEnabled
boolean isBoostProgressBarEnabled()Returns whether this Guild has its boost progress bar shown.- Returns:
- True, if this Guild has its boost progress bar shown
-
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
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
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
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
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:
-
requestToSpeak
Once the currently logged in account is connected to aStageChannel
, this will trigger aRequest-to-Speak
(aka raise your hand).This will set an internal flag to automatically request to speak once the bot joins a stage channel.
You can usecancelRequestToSpeak()
to move back to the audience or cancel your pending request.If the self member has
Permission.VOICE_MUTE_OTHERS
this will immediately promote them to speaker.Example:
stageChannel.createStageInstance("Talent Show").queue() guild.requestToSpeak(); // Set request to speak flag guild.getAudioManager().openAudioConnection(stageChannel); // join the channel
- Returns:
Task
representing the request to speak. CallingTask.get()
can result in deadlocks and should be avoided at all times.- See Also:
-
cancelRequestToSpeak
Cancels theRequest-to-Speak
.
This can also be used to move back to the audience if you are currently a speaker.If there is no request to speak or the member is not currently connected to a
StageChannel
, this does nothing.- Returns:
Task
representing the request to speak cancellation. CallingTask.get()
can result in deadlocks and should be avoided at all times.- See Also:
-
getJDA
Returns theJDA
instance of this Guild- Returns:
- the corresponding JDA instance
-
retrieveInvites
Retrieves allInvites
for this guild.
RequiresMANAGE_SERVER
in this guild. Will throw anInsufficientPermissionException
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:
-
retrieveTemplates
Retrieves allTemplates
for this guild.
RequiresMANAGE_SERVER
in this guild. Will throw anInsufficientPermissionException
otherwise.- Returns:
RestAction
- Type: List<Template
>
The list of Template objects- Throws:
InsufficientPermissionException
- if the account does not haveMANAGE_SERVER
in this Guild.
-
createTemplate
@Nonnull @CheckReturnValue RestAction<Template> createTemplate(@Nonnull String name, @Nullable String description) Used to create a newTemplate
for this Guild.
RequiresMANAGE_SERVER
in this Guild. Will throw anInsufficientPermissionException
otherwise.Possible
ErrorResponses
include:Guild already has a template
The guild already has a template.
- Parameters:
name
- The name of the templatedescription
- The description of the template- Returns:
RestAction
- Type:Template
The created Template object- Throws:
InsufficientPermissionException
- if the account does not haveMANAGE_SERVER
in this GuildIllegalArgumentException
- If the provided name isnull
or not between 1-100 characters long, or if the provided description is not between 0-120 characters long
-
retrieveWebhooks
Retrieves allWebhooks
for this Guild.
RequiresMANAGE_WEBHOOKS
in this Guild.To get all webhooks for a specific
TextChannel
, useBaseGuildMessageChannel.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:
-
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
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
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
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
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
-
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
-
findMembersWithRoles
@Nonnull @CheckReturnValue default Task<List<Member>> findMembersWithRoles(@Nonnull Collection<Role> roles) 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:
roles
- Collection of all roles the members must have- Returns:
Task
- Type:List
ofMember
- Throws:
IllegalArgumentException
- If null is providedIllegalStateException
- If theGatewayIntent.GUILD_MEMBERS
is not enabled- Since:
- 4.2.1
-
findMembersWithRoles
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:
roles
- All roles the members must have- Returns:
Task
- Type:List
ofMember
- Throws:
IllegalArgumentException
- If null is providedIllegalStateException
- If theGatewayIntent.GUILD_MEMBERS
is not enabled- Since:
- 4.2.1
-
loadMembers
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
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:
-
retrieveMemberById
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:
-
retrieveMemberById
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:
-
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:
-
retrieveMember
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:
-
retrieveMemberById
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:
-
retrieveMemberById
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:
-
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.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:
-
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
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
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 users
- 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:
-
retrieveActiveThreads
-
moveVoiceMember
@Nonnull @CheckReturnValue RestAction<Void> moveVoiceMember(@Nonnull Member member, @Nullable AudioChannel audioChannel) Used to move aMember
from oneAudioChannel
to anotherAudioChannel
.
As a note, you cannot move a Member that isn't already in a AudioChannel. Also they must be in a AudioChannel 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.audioChannel
- The destinationAudioChannel
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 AudioChannel in this Guild, orCacheFlag.VOICE_STATE
is disabled.IllegalArgumentException
-InsufficientPermissionException
-- If this account doesn't have
Permission.VOICE_MOVE_OTHERS
in the AudioChannel that the Member is currently in. - If this account AND the Member being moved don't have
Permission.VOICE_CONNECT
for the destination AudioChannel.
- If this account doesn't have
-
kickVoiceMember
Used to kick aMember
from aAudioChannel
.
As a note, you cannot kick a Member that isn't already in a AudioChannel. Also they must be in a AudioChannel 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 AudioChannel in this Guild, orCacheFlag.VOICE_STATE
is disabled.IllegalArgumentException
-InsufficientPermissionException
- If this account doesn't havePermission.VOICE_MOVE_OTHERS
in the AudioChannel 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)
IllegalArgumentException
- If the provided reason is longer than 512 characters
-
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.IllegalArgumentException
- If the provided reason is longer than 512 characters
-
kick
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
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 reason is longer than 512 characters.
- 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 reason is longer than 512 characters.
- 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 reason is longer than 512 characters.
- 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
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
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
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
-
timeoutFor
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutFor(@Nonnull Member member, long amount, @Nonnull TimeUnit unit) Puts the specified Member in time out in thisGuild
for a specific amount of time.
While a Member is in time out, they cannot send messages, reply, react, or speak in voice channels.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- The member to put in time outamount
- The amount of the providedunit
to put the specified Member in time out forunit
- TheUnit
type ofamount
- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.HierarchyException
- If the logged in account cannot put a timeout on the other Member due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
- If any of the following checks are true- The provided
member
is null - The provided
amount
is lower than or equal to0
- The provided
unit
is null - The provided
amount
with theunit
results in a date that is more than 28 days in the future
- The provided
-
timeoutFor
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutFor(@Nonnull Member member, @Nonnull Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- The member to put in time outduration
- The duration to put the specified Member in time out for- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.HierarchyException
- If the logged in account cannot put a timeout on the other Member due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
- If any of the following checks are true- The provided
member
is null - The provided
duration
is null - The provided
duration
results in a date that is more than 28 days in the future
- The provided
-
timeoutUntil
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutUntil(@Nonnull Member member, @Nonnull TemporalAccessor temporal) Puts the specified Member in time out in thisGuild
until the specified date.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- The member to put in time outtemporal
- The time the specified Member will be released from time out or null to remove the time out- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.HierarchyException
- If the logged in account cannot put a timeout on the other Member due to permission hierarchy position.
SeeMember.canInteract(Member)
IllegalArgumentException
- If any of the following are true- The provided
member
is null - The provided
temporal
is in the past - The provided
temporal
is more than 28 days in the future
- The provided
-
timeoutForById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutForById(long userId, long amount, @Nonnull TimeUnit unit) Puts a Member specified by the id in time out in thisGuild
for a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time outamount
- The amount of the providedunit
to put the specified Member in time out forunit
- TheUnit
type ofamount
- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If any of the following checks are true- The provided
userId
is not a valid snowflake - The provided
amount
is lower than or equal to0
- The provided
unit
is null - The provided
amount
with theunit
results in a date that is more than 28 days in the future
- The provided
-
timeoutForById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutForById(@Nonnull String userId, long amount, @Nonnull TimeUnit unit) Puts a Member specified by the id in time out in thisGuild
for a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time outamount
- The amount of the providedunit
to put the specified Member in time out forunit
- TheUnit
type ofamount
- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If any of the following checks are true- The provided
userId
is not a valid snowflake - The provided
amount
is lower than or equal to0
- The provided
unit
is null - The provided
amount
with theunit
results in a date that is more than 28 days in the future
- The provided
-
timeoutForById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutForById(long userId, @Nonnull Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time outduration
- The duration to put the specified Member in time out for- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If any of the following checks are true- The provided
userId
is not a valid snowflake - The provided
duration
is null - The provided
duration
is not positive - The provided
duration
results in a date that is more than 28 days in the future
- The provided
-
timeoutForById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutForById(@Nonnull String userId, @Nonnull Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time outduration
- The duration to put the specified Member in time out for- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If any of the following checks are true- The provided
userId
is not a valid snowflake - The provided
duration
is null - The provided
duration
is not positive - The provided
duration
results in a date that is more than 28 days in the future
- The provided
-
timeoutUntilById
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutUntilById(long userId, @Nonnull TemporalAccessor temporal) Puts a Member specified by the id in time out in thisGuild
until the specified date.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time outtemporal
- The time the specified Member will be released from time out or null to remove the time out- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If any of the following checks are true- The provided
userId
is not a valid snowflake - The provided
temporal
is in the past - The provided
temporal
is more than 28 days in the future
- The provided
-
timeoutUntilById
@Nonnull @CheckReturnValue AuditableRestAction<Void> timeoutUntilById(@Nonnull String userId, @Nonnull TemporalAccessor temporal) Puts a Member specified by the id in time out in thisGuild
until the specified date.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be timed out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time outtemporal
- The time the specified Member will be released from time out or null to remove the time out- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If any of the following checks are true- The provided
userId
is not a valid snowflake - The provided
temporal
is null - The provided
temporal
is in the past - The provided
temporal
is more than 28 days in the future
- The provided
-
removeTimeout
Removes a time out from the specified Member in thisGuild
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The time out cannot be removed due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
member
- The Member to remove a time out from- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.HierarchyException
- If the logged in account cannot remove the timeout from the other Member due to permission hierarchy position.
SeeMember.canInteract(Member)
-
removeTimeoutById
Removes a time out from a Member specified by the id in thisGuild
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The time out cannot be removed due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time out- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If the specified user id is not a valid snowflake
-
removeTimeoutById
Removes a time out from a Member specified by the id in thisGuild
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The time out cannot be removed due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Parameters:
userId
- The user id of the Member to put in time out- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MODERATE_MEMBERS
permission.IllegalArgumentException
- If the specified user id is not a valid snowflake
-
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
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
@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:
-
transferOwnership
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 default 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
-
createTextChannel
@Nonnull @CheckReturnValue ChannelAction<TextChannel> createTextChannel(@Nonnull String name, @Nullable Category parent) 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 createparent
- The optional parent category for this channel, or null- 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; or the provided parent is not in the same guild.
-
createNewsChannel
@Nonnull @CheckReturnValue default ChannelAction<NewsChannel> createNewsChannel(@Nonnull String name) Creates a newNewsChannel
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 NewsChannel to create- Returns:
- A specific
ChannelAction
This action allows to set fields for the new NewsChannel 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
-
createNewsChannel
@Nonnull @CheckReturnValue ChannelAction<NewsChannel> createNewsChannel(@Nonnull String name, @Nullable Category parent) Creates a newNewsChannel
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 NewsChannel to createparent
- The optional parent category for this channel, or null- Returns:
- A specific
ChannelAction
This action allows to set fields for the new NewsChannel 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; or the provided parent is not in the same guild.
-
createVoiceChannel
@Nonnull @CheckReturnValue default 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
-
createVoiceChannel
@Nonnull @CheckReturnValue ChannelAction<VoiceChannel> createVoiceChannel(@Nonnull String name, @Nullable Category parent) 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 createparent
- The optional parent category for this channel, or null- 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; or the provided parent is not in the same guild.
-
createStageChannel
@Nonnull @CheckReturnValue default ChannelAction<StageChannel> createStageChannel(@Nonnull String name) Creates a newStageChannel
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 StageChannel to create- Returns:
- A specific
ChannelAction
This action allows to set fields for the new StageChannel 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
-
createStageChannel
@Nonnull @CheckReturnValue ChannelAction<StageChannel> createStageChannel(@Nonnull String name, @Nullable Category parent) Creates a newStageChannel
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 StageChannel to createparent
- The optional parent category for this channel, or null- Returns:
- A specific
ChannelAction
This action allows to set fields for the new StageChannel 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; or the provided parent is not in the same guild.
-
createCategory
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 ICopyableChannel> 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:
-
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
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_AND_STICKERS
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_AND_STICKERS
Permission
-
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
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
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
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
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
-