Interface Guild
- All Superinterfaces:
IGuildChannelContainer<GuildChannel>
,ISnowflake
Guild
.
This should contain all information provided from Discord about a Guild.- See Also:
-
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 TypeMethodDescriptionaddMember
(String accessToken, UserSnowflake user) Adds the user to this guild as a member.addRoleToMember
(UserSnowflake user, Role role) default AuditableRestAction
<BulkBanResponse> ban
(Collection<? extends UserSnowflake> users, int deletionTimeframe, TimeUnit unit) Bans up to 200 of the provided users.ban
(Collection<? extends UserSnowflake> users, Duration deletionTime) Bans up to 200 of the provided users.ban
(UserSnowflake user, int deletionTimeframe, TimeUnit unit) Bans the user specified by the providedUserSnowflake
and deletes messages sent by the user based on thedeletionTimeframe
.Cancels theRequest-to-Speak
.Creates a newAutoModRule
for this guild.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) createEmoji
(String name, Icon icon, Role... roles) Creates a newRichCustomEmoji
in this Guild.default ChannelAction
<ForumChannel> createForumChannel
(String name) Creates a newForumChannel
in this Guild.createForumChannel
(String name, Category parent) Creates a newForumChannel
in this Guild.default ChannelAction
<MediaChannel> createMediaChannel
(String name) Creates a newMediaChannel
in this Guild.createMediaChannel
(String name, Category parent) Creates a newMediaChannel
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.createScheduledEvent
(String name, String location, OffsetDateTime startTime, OffsetDateTime endTime) Creates a newScheduledEvent
.createScheduledEvent
(String name, GuildChannel channel, OffsetDateTime startTime) Creates a newScheduledEvent
.default ChannelAction
<StageChannel> createStageChannel
(String name) Creates a newStageChannel
in this Guild.createStageChannel
(String name, Category parent) Creates a newStageChannel
in this Guild.default AuditableRestAction
<GuildSticker> createSticker
(String name, String description, FileUpload file, String tag, String... tags) Creates a newGuildSticker
in this Guild.createSticker
(String name, String description, FileUpload file, Collection<String> tags) Creates a newGuildSticker
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.deafen
(UserSnowflake user, boolean deafen) Sets the Guild Deafened state of theMember
based on the provided boolean.delete()
Used to completely delete a Guild.Used to completely delete a guild.default AuditableRestAction
<Void> deleteAutoModRuleById
(long id) Deletes theAutoModRule
for the provided id.Deletes theAutoModRule
for the provided id.default RestAction
<Void> deleteCommandById
(long commandId) Delete the command for this id.deleteCommandById
(String commandId) Delete the command for this id.Deletes a sticker from the guild.default CommandEditAction
editCommandById
(long id) Edit an existing command by id.Edit an existing command by id.editSticker
(StickerSnowflake sticker) Modify a sticker usingGuildStickerManager
.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.default ImageProxy
Returns anImageProxy
for this guild's banner image.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).SortedSnowflakeCacheView
ofCategory
.default @Unmodifiable List
<GuildChannel> Populated list ofchannels
for this guild.@Unmodifiable List
<GuildChannel> getChannels
(boolean includeHidden) Populated list ofchannels
for this guild.Provides theTextChannel
that receives community updates.The defaultStandardGuildChannel
for aGuild
.Returns the default message Notification-Level of this Guild.The description for this guild.default RichCustomEmoji
getEmojiById
(long id) Gets anRichCustomEmoji
from this guild that has the same id as the one provided.default RichCustomEmoji
getEmojiById
(String id) Gets aRichCustomEmoji
from this guild that has the same id as the one provided.SnowflakeCacheView
of all cachedCustom Emojis
of this Guild.default @Unmodifiable List
<RichCustomEmoji> Gets allCustom Emojis
belonging to thisGuild
.default @Unmodifiable List
<RichCustomEmoji> getEmojisByName
(String name, boolean ignoreCase) Gets a list of allCustom Emojis
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 ImageProxy
getIcon()
Returns anImageProxy
for this guild's icon.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 custom emojis 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.getMember
(UserSnowflake user) Gets the Guild specificMember
object for the providedUserSnowflake
.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
.SortedSnowflakeCacheView
ofNewsChannel
.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.Provides theTextChannel
that receives discord safety alerts.default ScheduledEvent
getScheduledEventById
(long id) Gets aScheduledEvent
from this guild that has the same id as the one provided.default ScheduledEvent
Gets aScheduledEvent
from this guild that has the same id as the one provided.SortedSnowflakeCacheView
of all cachedScheduledEvents
of this Guild.default @Unmodifiable List
<ScheduledEvent> Gets allScheduledEvents
in this guild.default @Unmodifiable List
<ScheduledEvent> getScheduledEventsByName
(String name, boolean ignoreCase) Gets a list of allScheduledEvents
in this Guild that have the same name as the one provided.Gets theMember
object of the currently logged in account in this guild.default ImageProxy
Returns anImageProxy
for this guild's splash icon.The Discord hash-id of the splash image for this Guild.default String
The URL of the splash image for this Guild.SortedSnowflakeCacheView
ofStageChannel
.default GuildSticker
getStickerById
(long id) Gets aGuildSticker
from this guild that has the same id as the one provided.default GuildSticker
getStickerById
(String id) Gets aGuildSticker
from this guild that has the same id as the one provided.SnowflakeCacheView
of all cachedGuildStickers
of this Guild.default @Unmodifiable List
<GuildSticker> Gets all customGuildStickers
belonging to thisGuild
.default @Unmodifiable List
<GuildSticker> getStickersByName
(String name, boolean ignoreCase) Gets a list of allGuildStickers
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.SortedSnowflakeCacheView
ofTextChannel
.The vanity url code for this Guild.default String
The vanity url for this Guild.Returns the verification-Level of this Guild.SortedSnowflakeCacheView
ofVoiceChannel
.boolean
Returns whether this Guild has its boost progress bar shown.default boolean
Whether the invites for this guild are paused/disabled.boolean
isLoaded()
Whether this guild has loaded members.boolean
isMember
(UserSnowflake user) Used to determine if the providedUserSnowflake
is a member of this Guild.kick
(UserSnowflake user) default AuditableRestAction
<Void> kick
(UserSnowflake user, String reason) Deprecated.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.default AutoModRuleManager
modifyAutoModRuleById
(long id) Returns anAutoModRuleManager
, which can be used to modify the rule for the provided id.Returns anAutoModRuleManager
, which can be used to modify the rule for the provided id.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
.TheManager
for this guild's welcome screen, used to modify properties of the welcome screen like if the welcome screen is enabled, the description and welcome channels.moveVoiceMember
(Member member, AudioChannel audioChannel) mute
(UserSnowflake user, boolean mute) Sets the Guild Muted 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.removeRoleFromMember
(UserSnowflake user, Role role) removeTimeout
(UserSnowflake user) Removes a time out from the specified Member in thisGuild
.Once the currently logged in account is connected to aStageChannel
, this will trigger aRequest-to-Speak
(aka raise your hand).RestAction
<@Unmodifiable List<ThreadChannel>> Retrieves the active threads in this guild.default RestAction
<AutoModRule> retrieveAutoModRuleById
(long id) Retrieves theAutoModRule
for the provided id.Retrieves theAutoModRule
for the provided id.RestAction
<@Unmodifiable List<AutoModRule>> Retrieves all currentAutoModRules
for this guild.retrieveBan
(UserSnowflake user) Retrieves aBan
of the providedUserSnowflake
.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 theIntegrationPrivileges
for the commands in this guild.default RestAction
<List<Command>> Retrieves the list of guild commands.retrieveCommands
(boolean withLocalizations) Retrieves the list of guild commands.default RestAction
<RichCustomEmoji> retrieveEmoji
(CustomEmoji emoji) Retrieves a custom emoji together with its respective creator.default RestAction
<RichCustomEmoji> retrieveEmojiById
(long id) Retrieves a Custom Emoji together with its respective creator.Retrieves a custom emoji together with its respective creator.RestAction
<@Unmodifiable List<RichCustomEmoji>> Retrieves an immutable list of Custom Emojis together with their respective creators.default RestAction
<List<IntegrationPrivilege>> retrieveIntegrationPrivilegesById
(long targetId) Retrieves theIntegrationPrivileges
for the target with the specified ID.retrieveIntegrationPrivilegesById
(String targetId) Retrieves theIntegrationPrivileges
for the target with the specified ID.RestAction
<@Unmodifiable List<Invite>> Retrieves allInvites
for this guild.default CacheRestAction
<Member> retrieveMember
(UserSnowflake user) Load the member for the specifiedUserSnowflake
.retrieveMemberById
(long id) Load the member for the specified user.default CacheRestAction
<Member> Load the member for the specified user.retrieveMembers
(boolean includePresence, Collection<? extends UserSnowflake> users) Retrieves a list of members.retrieveMembers
(Collection<? extends UserSnowflake> 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 CacheRestAction
<Member> 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 Guilddefault CacheRestAction
<ScheduledEvent> retrieveScheduledEventById
(long id) Retrieves aScheduledEvent
by its ID.Retrieves aScheduledEvent
by its ID.retrieveSticker
(StickerSnowflake sticker) Attempts to retrieve aGuildSticker
object for this guild based on the provided snowflake reference.RestAction
<@Unmodifiable List<GuildSticker>> Retrieves all the stickers from this guild.RestAction
<@Unmodifiable List<Template>> Retrieves allTemplates
for this guild.Retrieves the Vanity Invite meta data for this guild.RestAction
<@Unmodifiable List<Webhook>> Retrieves allWebhooks
for this Guild.Retrieves thewelcome screen
for this Guild.default AuditableRestAction
<Void> timeoutFor
(UserSnowflake user, long amount, TimeUnit unit) Puts the specified Member in time out in thisGuild
for a specific amount of time.default AuditableRestAction
<Void> timeoutFor
(UserSnowflake user, Duration duration) Puts the specified Member in time out in thisGuild
for a specific amount of time.timeoutUntil
(UserSnowflake user, TemporalAccessor temporal) Puts the specified Member 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 Guildunban
(UserSnowflake user) Unbans the specifiedUserSnowflake
from this Guild.boolean
unloadMember
(long userId) Attempts to remove the user with the provided id from the member cache.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.channel.attribute.IGuildChannelContainer
getCategories, getCategoriesByName, getCategoryById, getCategoryById, getChannelById, getChannelById, getForumChannelById, getForumChannelById, getForumChannels, getForumChannelsByName, getGuildChannelById, getGuildChannelById, getGuildChannelById, getGuildChannelById, getMediaChannelById, getMediaChannelById, getMediaChannelCache, getMediaChannels, getMediaChannelsByName, getNewsChannelById, getNewsChannelById, getNewsChannels, getNewsChannelsByName, getStageChannelById, getStageChannelById, getStageChannels, getStageChannelsByName, getTextChannelById, getTextChannelById, getTextChannels, getTextChannelsByName, getThreadChannelById, getThreadChannelById, getThreadChannels, getThreadChannelsByName, getVoiceChannelById, getVoiceChannelById, getVoiceChannels, getVoiceChannelsByName
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.
This list does not include localization data. UseretrieveCommands(boolean)
to get localization data- Returns:
RestAction
- Type:List
ofCommand
-
retrieveCommands
Retrieves the list of guild commands.
This list does not include global commands! UseJDA.retrieveCommands()
for global commands.- Parameters:
withLocalizations
-true
if the localization data (such as name and description) should be included- 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)) .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.BAN_MEMBERS)) .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
-
retrieveIntegrationPrivilegesById
@Nonnull @CheckReturnValue RestAction<List<IntegrationPrivilege>> retrieveIntegrationPrivilegesById(@Nonnull String targetId) Retrieves theIntegrationPrivileges
for the target with the specified ID.
The ID can either be of a Command or Application!Moderators of a guild can modify these privileges through the Integrations Menu
If there is no command or application with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
targetId
- The id of the command (global or guild), or application- Returns:
RestAction
- Type:List
ofIntegrationPrivilege
- Throws:
IllegalArgumentException
- If the id is not a valid snowflake
-
retrieveIntegrationPrivilegesById
@Nonnull @CheckReturnValue default RestAction<List<IntegrationPrivilege>> retrieveIntegrationPrivilegesById(long targetId) Retrieves theIntegrationPrivileges
for the target with the specified ID.
The ID can either be of a Command or Application!Moderators of a guild can modify these privileges through the Integrations Menu
If there is no command or application with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Parameters:
targetId
- The id of the command (global or guild), or application- Returns:
RestAction
- Type:List
ofIntegrationPrivilege
- Throws:
IllegalArgumentException
- If the id is not a valid snowflake
-
retrieveCommandPrivileges
Retrieves theIntegrationPrivileges
for the commands in this guild.
The RestAction provides aPrivilegeConfig
providing the privileges of this application and its commands.Moderators of a guild can modify these privileges through the Integrations Menu
- Returns:
RestAction
- Type:PrivilegeConfig
-
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
-
retrieveAutoModRules
Retrieves all currentAutoModRules
for this guild.- Returns:
RestAction
- Type:List
ofAutoModRule
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission
-
retrieveAutoModRuleById
Retrieves theAutoModRule
for the provided id.- Parameters:
id
- The id of the rule- Returns:
RestAction
- Type:AutoModRule
- Throws:
IllegalArgumentException
- If the provided id is not a valid snowflakeInsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission
-
retrieveAutoModRuleById
Retrieves theAutoModRule
for the provided id.- Parameters:
id
- The id of the rule- Returns:
RestAction
- Type:AutoModRule
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission
-
createAutoModRule
@Nonnull @CheckReturnValue AuditableRestAction<AutoModRule> createAutoModRule(@Nonnull AutoModRuleData data) Creates a newAutoModRule
for this guild.You can only create a certain number of rules for each
AutoModTriggerType
. The maximum is provided byAutoModTriggerType.getMaxPerGuild()
.- Parameters:
data
- The data for the new rule- Returns:
AuditableRestAction
- Type:AutoModRule
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have therequired permissions
IllegalStateException
-- If the provided data does not have any
AutoModResponse
configured - If any of the configured
AutoModResponses
is not supported by theAutoModTriggerType
- If the provided data does not have any
-
modifyAutoModRuleById
Returns anAutoModRuleManager
, which can be used to modify the rule for the provided id.The manager allows modifying multiple fields in a single request.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The manager instance
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission.
-
modifyAutoModRuleById
Returns anAutoModRuleManager
, which can be used to modify the rule for the provided id.The manager allows modifying multiple fields in a single request.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The manager instance
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission.
-
deleteAutoModRuleById
Deletes theAutoModRule
for the provided id.- Parameters:
id
- The id of the rule- Returns:
AuditableRestAction
- Type:Void
- Throws:
IllegalArgumentException
- If the provided id is not a valid snowflakeInsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission
-
deleteAutoModRuleById
Deletes theAutoModRule
for the provided id.- Parameters:
id
- The id of the rule- Returns:
AuditableRestAction
- Type:Void
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_SERVER
permission
-
addMember
@Nonnull @CheckReturnValue MemberAction addMember(@Nonnull String accessToken, @Nonnull UserSnowflake user) Adds the user to this guild as a member.
This requires an OAuth2 Access Token with the scopeguilds.join
.- Parameters:
accessToken
- The access tokenuser
- TheUserSnowflake
for the member to add. This can be a member or user instance orUser.fromId(long)
.- Returns:
MemberAction
- Throws:
IllegalArgumentException
- If the access token is blank, empty, or null, or if the provided user reference is null or 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.
-
getIcon
Returns anImageProxy
for this guild's icon.- Returns:
- The
ImageProxy
of this guild's icon - See Also:
-
getFeatures
The Features of theGuild
.Features can be updated using
GuildManager.setFeatures(Collection)
.- Returns:
- Never-null, unmodifiable Set containing all of the Guild's features.
- See Also:
-
isInvitesDisabled
default boolean isInvitesDisabled()Whether the invites for this guild are paused/disabled.
This is equivalent togetFeatures().contains("INVITES_DISABLED")
.- Returns:
- True, if invites are paused/disabled
-
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.
-
getSplash
Returns anImageProxy
for this guild's splash icon.- Returns:
- Possibly-null
ImageProxy
of this guild's splash icon - See Also:
-
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:DiscordLocale.ENGLISH_US
- Returns:
- The preferred
DiscordLocale
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
-
getBanner
Returns anImageProxy
for this guild's banner image.- Returns:
- Possibly-null
ImageProxy
of this guild's banner image - See Also:
-
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.This will only check cached members!
SeeMemberCachePolicy
- Returns:
- 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
-
getMaxEmojis
default int getMaxEmojis()The maximum amount of custom emojis a guild can have based on the guilds boost tier.- Returns:
- The maximum amount of custom emojis
-
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:
-
getSafetyAlertsChannel
Provides theTextChannel
that receives discord safety alerts.
If this guild doesn't have the COMMUNITYfeature
, this returnsnull
.- Returns:
- Possibly-null
TextChannel
that is the saferty alerts 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 providedUserSnowflake
is a member of this Guild.This will only check cached members! If the cache is not loaded (see
isLoaded()
), this may return false despite the user being a member. This is false whengetMember(UserSnowflake)
returnsnull
.- Parameters:
user
- The user to check- Returns:
- True - if this user is present and cached in this guild
-
getSelfMember
Gets theMember
object of the currently logged in account in this guild.
This is basicallyJDA.getSelfUser()
being provided togetMember(UserSnowflake)
.- 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 providedUserSnowflake
.
If the user is not in this guild or currently uncached,null
is returned.This will only check cached members!
- Parameters:
user
- TheUserSnowflake
for the member to get. This can be a member or user instance orUser.fromId(long)
.- 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(UserSnowflake)
.
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(UserSnowflake)
.
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
@Nonnull @Incubating default @Unmodifiable List<Member> getMembersByName(@Nonnull String name, boolean ignoreCase) Gets a list of allMembers
who have the same name as the one provided.
This compares againstMember.getUser()
.getName()
If there are noMembers
with the provided name, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy
- Parameters:
name
- The name used to filter the returned Members.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Members with the same name as the name provided.
- Throws:
IllegalArgumentException
- If the provided name is null- See Also:
- Incubating:
- This will be replaced in the future when the rollout of globally unique usernames has been completed.
-
getMembersByNickname
@Nonnull default @Unmodifiable List<Member> getMembersByNickname(@Nullable String nickname, boolean ignoreCase) Gets a list of allMembers
who have the same nickname as the one provided.
This compares againstMember.getNickname()
. If a Member does not have a nickname, the comparison results as false.
If there are noMembers
with the provided name, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy
- Parameters:
nickname
- The nickname used to filter the returned Members.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Members with the same nickname as the nickname provided.
- See Also:
-
getMembersByEffectiveName
@Nonnull default @Unmodifiable List<Member> getMembersByEffectiveName(@Nonnull String name, boolean ignoreCase) Gets a list of allMembers
who have the same effective name as the one provided.
This compares againstMember.getEffectiveName()
.
If there are noMembers
with the provided name, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy
- Parameters:
name
- The name used to filter the returned Members.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Members with the same effective name as the name provided.
- Throws:
IllegalArgumentException
- If the provided name is null- See Also:
-
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:
-
getScheduledEventCache
SortedSnowflakeCacheView
of all cachedScheduledEvents
of this Guild.
Scheduled events are sorted by their start time, and events that start at the same time are sorted by their snowflake ID.This requires
CacheFlag.SCHEDULED_EVENTS
to be enabled.- Returns:
SortedSnowflakeCacheView
-
getScheduledEventsByName
@Nonnull default @Unmodifiable List<ScheduledEvent> getScheduledEventsByName(@Nonnull String name, boolean ignoreCase) Gets a list of allScheduledEvents
in this Guild that have the same name as the one provided.
If there are noScheduledEvents
with the provided name, then this returns an empty list.This requires
CacheFlag.SCHEDULED_EVENTS
to be enabled.- Parameters:
name
- The name used to filter the returnedScheduledEvent
objects.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all ScheduledEvent names that match the provided name.
- Throws:
IllegalArgumentException
- If the name is blank, empty ornull
-
getScheduledEventById
Gets aScheduledEvent
from this guild that has the same id as the one provided. This method is similar toJDA.getScheduledEventById(String)
, but it only checks this specific Guild for a scheduled event.
If there is noScheduledEvent
with an id that matches the provided one, then this returnsnull
.This requires
CacheFlag.SCHEDULED_EVENTS
to be enabled.- Parameters:
id
- The id of theScheduledEvent
.- Returns:
- Possibly-null
ScheduledEvent
with matching id. - Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getScheduledEventById
Gets aScheduledEvent
from this guild that has the same id as the one provided. This method is similar toJDA.getScheduledEventById(long)
, but it only checks this specific Guild for a scheduled event.
If there is noScheduledEvent
with an id that matches the provided one, then this returnsnull
.This requires
CacheFlag.SCHEDULED_EVENTS
to be enabled.- Parameters:
id
- The id of theScheduledEvent
.- Returns:
- Possibly-null
ScheduledEvent
with matching id.
-
getScheduledEvents
Gets allScheduledEvents
in this guild.
Scheduled events are sorted by their start time, and events that start at the same time are sorted by their snowflake ID.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
getScheduledEventCache()
and use its more efficient versions of handling these values.This requires
CacheFlag.SCHEDULED_EVENTS
to be enabled.- Returns:
- Possibly-empty immutable List of
ScheduledEvents
.
-
getStageChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofStageChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getStageChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getThreadChannelCache
Description copied from interface:IGuildChannelContainer
SnowflakeCacheView
ofThreadChannel
.These threads can also represent posts in
ForumChannels
.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getThreadChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SnowflakeCacheView
-
getCategoryCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofCategory
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getCategoryCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getTextChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofTextChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getTextChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getNewsChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofNewsChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getNewsChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getVoiceChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofVoiceChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getVoiceChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getForumChannelCache
Description copied from interface:IGuildChannelContainer
SnowflakeCacheView
ofForumChannel
.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getForumChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SnowflakeCacheView
-
getChannelCache
SortedChannelCacheView
ofGuildChannel
.Provides cache access to all channels of this guild, including thread channels (unlike
getChannels()
). The cache view attempts to provide a sorted list, based on how channels are displayed in the client. Various methods likeCacheView.forEachUnordered(Consumer)
orCacheView.lockedIterator()
bypass sorting for optimization reasons.It is possible to filter the channels to more specific types using
ChannelCacheView.getElementById(ChannelType, long)
orSortedChannelCacheView.ofType(Class)
.- Specified by:
getChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedChannelCacheView
-
getChannels
Populated list ofchannels
for this guild.
This includes all types of channels, except for threads.
This includes hidden channels by default, you can usegetChannels(false)
to exclude hidden channels.The returned list is ordered in the same fashion as it would be by the official discord client.
- TextChannel, ForumChannel, and NewsChannel without parent
- VoiceChannel and StageChannel without parent
- Categories
- TextChannel, ForumChannel, and NewsChannel with category as parent
- VoiceChannel and 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, except for threads.The returned list is ordered in the same fashion as it would be by the official discord client.
- TextChannel, ForumChannel, and NewsChannel without parent
- VoiceChannel and StageChannel without parent
- Categories
- TextChannel, ForumChannel, and NewsChannel with category as parent
- VoiceChannel and 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
-
getEmojiById
Gets aRichCustomEmoji
from this guild that has the same id as the one provided.
If there is noRichCustomEmoji
with an id that matches the provided one, then this returnsnull
.Unicode emojis are not included as
RichCustomEmoji
!This requires the
CacheFlag.EMOJI
to be enabled!- Parameters:
id
- the emoji id- Returns:
- An Emoji matching the specified id
- Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
- See Also:
-
getEmojiById
Gets anRichCustomEmoji
from this guild that has the same id as the one provided.
If there is noRichCustomEmoji
with an id that matches the provided one, then this returnsnull
.Unicode emojis are not included as
RichCustomEmoji
!This requires the
CacheFlag.EMOJI
to be enabled!- Parameters:
id
- the emoji id- Returns:
- An emoji matching the specified id
- See Also:
-
getEmojis
Gets allCustom Emojis
belonging to thisGuild
.
Emojis are not ordered in any specific way in the returned list.Unicode emojis are not included as
RichCustomEmoji
!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
getEmojiCache()
and use its more efficient versions of handling these values.This requires the
CacheFlag.EMOJI
to be enabled!- Returns:
- An immutable List of
Custom Emojis
. - See Also:
-
getEmojisByName
@Nonnull default @Unmodifiable List<RichCustomEmoji> getEmojisByName(@Nonnull String name, boolean ignoreCase) Gets a list of allCustom Emojis
in this Guild that have the same name as the one provided.
If there are noEmojis
with the provided name, then this returns an empty list.Unicode emojis are not included as
RichCustomEmoji
!This requires the
CacheFlag.EMOJI
to be enabled!- Parameters:
name
- The name used to filter the returnedEmojis
. Without colons.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Emojis that match the provided name.
-
getEmojiCache
SnowflakeCacheView
of all cachedCustom Emojis
of this Guild.
This will be empty ifCacheFlag.EMOJI
is disabled.This requires the
CacheFlag.EMOJI
to be enabled!- Returns:
SnowflakeCacheView
- See Also:
-
getStickerById
Gets aGuildSticker
from this guild that has the same id as the one provided.
If there is noGuildSticker
with an id that matches the provided one, then this returnsnull
.This requires the
CacheFlag.STICKER
to be enabled!- Parameters:
id
- the sticker id- Returns:
- A Sticker matching the specified id
- Throws:
NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
- See Also:
-
getStickerById
Gets aGuildSticker
from this guild that has the same id as the one provided.
If there is noGuildSticker
with an id that matches the provided one, then this returnsnull
.This requires the
CacheFlag.STICKER
to be enabled!- Parameters:
id
- the sticker id- Returns:
- A Sticker matching the specified id
- See Also:
-
getStickers
Gets all customGuildStickers
belonging to thisGuild
.
GuildStickers are not ordered in any specific way in the returned list.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
getStickerCache()
and use its more efficient versions of handling these values.This requires the
CacheFlag.STICKER
to be enabled!- Returns:
- An immutable List of
GuildStickers
. - See Also:
-
getStickersByName
@Nonnull default @Unmodifiable List<GuildSticker> getStickersByName(@Nonnull String name, boolean ignoreCase) Gets a list of allGuildStickers
in this Guild that have the same name as the one provided.
If there are noGuildStickers
with the provided name, then this returns an empty list.This requires the
CacheFlag.STICKER
to be enabled!- Parameters:
name
- The name used to filter the returnedGuildStickers
. Without colons.ignoreCase
- Determines if the comparison ignores case when comparing. True - case insensitive.- Returns:
- Possibly-empty immutable list of all Stickers that match the provided name.
-
getStickerCache
SnowflakeCacheView
of all cachedGuildStickers
of this Guild.
This will be empty ifCacheFlag.STICKER
is disabled.This requires the
CacheFlag.STICKER
to be enabled!- Returns:
SnowflakeCacheView
- See Also:
-
retrieveEmojis
Retrieves an immutable list of Custom Emojis together with their respective creators.Note that
RichCustomEmoji.getOwner()
is only available if the currently logged in account hasPermission.MANAGE_GUILD_EXPRESSIONS
.- Returns:
RestAction
- Type: List ofRichCustomEmoji
-
retrieveEmojiById
Retrieves a custom emoji together with its respective creator.
This does not include unicode emoji.Note that
RichCustomEmoji.getOwner()
is only available if the currently logged in account hasPermission.MANAGE_GUILD_EXPRESSIONS
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided id does not correspond to an emoji in this guild
- Parameters:
id
- The emoji id- Returns:
RestAction
- Type:RichCustomEmoji
- Throws:
IllegalArgumentException
- If the provided id is not a valid snowflake
-
retrieveEmojiById
Retrieves a Custom Emoji together with its respective creator.Note that
RichCustomEmoji.getOwner()
is only available if the currently logged in account hasPermission.MANAGE_GUILD_EXPRESSIONS
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided id does not correspond to an emoji in this guild
- Parameters:
id
- The emoji id- Returns:
RestAction
- Type:RichCustomEmoji
-
retrieveEmoji
@Nonnull @CheckReturnValue default RestAction<RichCustomEmoji> retrieveEmoji(@Nonnull CustomEmoji emoji) Retrieves a custom emoji together with its respective creator.Note that
RichCustomEmoji.getOwner()
is only available if the currently logged in account hasPermission.MANAGE_GUILD_EXPRESSIONS
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided emoji does not correspond to an emoji in this guild anymore
- Parameters:
emoji
- The emoji reference to retrieve- Returns:
RestAction
- Type:RichCustomEmoji
-
retrieveStickers
Retrieves all the stickers from this guild.
This also includesunavailable
stickers.- Returns:
RestAction
- Type: List ofGuildSticker
-
retrieveSticker
@Nonnull @CheckReturnValue RestAction<GuildSticker> retrieveSticker(@Nonnull StickerSnowflake sticker) Attempts to retrieve aGuildSticker
object for this guild based on the provided snowflake reference.The returned
RestAction
can encounter the following Discord errors:UNKNOWN_STICKER
Occurs when the provided id does not refer to a sticker known by Discord.
- Parameters:
sticker
- The reference of the requestedSticker
.
Can beRichSticker
,StickerItem
, orSticker.fromId(long)
.- Returns:
RestAction
- Type:GuildSticker
On request, gets the sticker with id matching provided id from Discord.- Throws:
IllegalArgumentException
- If null is provided
-
editSticker
Modify a sticker usingGuildStickerManager
.
You can update multiple fields at once, by calling the respective setters before executing the request.The returned
RestAction
can encounter the following Discord errors:UNKNOWN_STICKER
Occurs when the provided id does not refer to a sticker known by Discord.
- Returns:
GuildStickerManager
- Throws:
IllegalArgumentException
- If null is providedInsufficientPermissionException
- If the currently logged in account does not haveMANAGE_GUILD_EXPRESSIONS
in the guild.
-
retrieveBanList
Retrieves an immutable list of the currently bannedUsers
.
If you wish to ban or unban a user, use eitherban(UserSnowflake, int, TimeUnit)
orunban(UserSnowflake)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancy
- Returns:
- The
BanPaginationAction
of the guild's bans. - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.
-
retrieveBan
Retrieves aBan
of the providedUserSnowflake
.
If you wish to ban or unban a user, use eitherban(UserSnowflake, int, TimeUnit)
orunban(UserSnowflake)
.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:
user
- TheUserSnowflake
for the banned user. This can be a user instance orUser.fromId(long)
.- 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 defaultStandardGuildChannel
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 specificchannel
.Note: This channel is the first channel in the guild (ordered by position) that the
getPublicRole()
has thePermission.VIEW_CHANNEL
in.- Returns:
- The
channel
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()
.- 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
, useIWebhookContainer.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:
-
retrieveWelcomeScreen
Retrieves thewelcome screen
for this Guild.
The welcome screen is shown to all members after joining the Guild.Possible
ErrorResponses
include:Unknown Guild Welcome Screen
The guild has no welcome screenMissing Permissions
The guild's welcome screen is disabled and the currently logged in account doesn't have theMANAGE_SERVER
permission
- Returns:
RestAction
- Type:GuildWelcomeScreen
The welcome screen for this Guild.
-
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
@Nonnull @CheckReturnValue default CacheRestAction<Member> retrieveMember(@Nonnull UserSnowflake user) Load the member for the specifiedUserSnowflake
.
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 useuseCache(false)
to always make a new request, which is the default behavior if the required intents are disabled.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
- TheUserSnowflake
for the member to retrieve. This can be a member or user instance orUser.fromId(long)
.- Returns:
RestAction
- Type:Member
- Throws:
IllegalArgumentException
- If provided with null- 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.
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 useuseCache(false)
to always make a new request, which is the default behavior if the required intents are disabled.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:
-
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 useuseCache(false)
to always make a new request, which is the default behavior if the required intents are disabled.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 useuseCache(false)
to always make a new request, which is the default behavior if the required intents are disabled.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:
-
retrieveMembers
@Nonnull @CheckReturnValue default Task<List<Member>> retrieveMembers(@Nonnull Collection<? extends UserSnowflake> 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<? extends UserSnowflake> 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
Retrieves the active threads in this guild.- Returns:
RestAction
- List ofThreadChannel
-
retrieveScheduledEventById
@Nonnull @CheckReturnValue default CacheRestAction<ScheduledEvent> retrieveScheduledEventById(long id) Retrieves aScheduledEvent
by its ID.Possible
ErrorResponses
include:ErrorResponse.UNKNOWN_SCHEDULED_EVENT
A scheduled event with the specified ID does not exist in the guild, or the currently logged in user does not have access to it.
- Parameters:
id
- The ID of theScheduledEvent
- Returns:
RestAction
- Type:ScheduledEvent
- See Also:
-
retrieveScheduledEventById
@Nonnull @CheckReturnValue CacheRestAction<ScheduledEvent> retrieveScheduledEventById(@Nonnull String id) Retrieves aScheduledEvent
by its ID.Possible
ErrorResponses
include:ErrorResponse.UNKNOWN_SCHEDULED_EVENT
A scheduled event with the specified ID does not exist in this guild, or the currently logged in user does not have access to it.
- Parameters:
id
- The ID of theScheduledEvent
- Returns:
RestAction
- Type:ScheduledEvent
- Throws:
IllegalArgumentException
- If the specified ID isnull
or emptyNumberFormatException
- If the specified ID cannot be parsed byLong.parseLong(String)
- See Also:
-
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 @Deprecated @ForRemoval @ReplaceWith("kick(user).reason(reason)") @DeprecatedSince("5.0.0") default AuditableRestAction<Void> kick(@Nonnull UserSnowflake user, @Nullable String reason) Deprecated.Usekick(UserSnowflake)
andAuditableRestAction.reason(String)
instead.Kicks theUserSnowflake
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:
user
- TheUserSnowflake
for the user to kick. This can be a member or user instance orUser.fromId(long)
.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 cannot be kicked from this Guild or the provided
user
is null. - If the provided reason is longer than 512 characters
- If the user cannot be kicked from this Guild or the provided
-
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:
user
- TheUserSnowflake
for the user to kick. This can be a member or user instance orUser.fromId(long)
.- Returns:
AuditableRestAction
Kicks the provided Member from the current Guild- Throws:
IllegalArgumentException
- If the user cannot be kicked from this Guild or the provideduser
is null.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)
)
-
ban
@Nonnull @CheckReturnValue AuditableRestAction<Void> ban(@Nonnull UserSnowflake user, int deletionTimeframe, @Nonnull TimeUnit unit) Bans the user specified by the providedUserSnowflake
and deletes messages sent by the user based on thedeletionTimeframe
.
If you wish to ban a user without deleting any messages, providedeletionTimeframe
with a value of 0. To set a ban reason, useAuditableRestAction.reason(String)
.You can unban a user with
Guild.unban(UserReference)
.Note:
getMembers()
will still contain theUser's
Member
object (if the User was in the Guild) until Discord sends theGuildMemberRemoveEvent
.Examples
Banning a user without deleting any messages:
Banning a user and deleting messages from the past hour:guild.ban(user, 0, TimeUnit.SECONDS) .reason("Banned for rude behavior") .queue();
guild.ban(user, 1, TimeUnit.HOURS) .reason("Banned for spamming") .queue();
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_USER
The user does not exist
- Parameters:
user
- TheUserSnowflake
for the user to ban. This can be a member or user instance orUser.fromId(long)
.deletionTimeframe
- The timeframe for the history of messages that will be deleted. (seconds precision)unit
- Timeframe unit as aTimeUnit
(for exampleban(user, 7, TimeUnit.DAYS)
).- 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 deletionTimeframe is negative.
- If the provided deletionTimeframe is longer than 7 days.
- If the provided user or time unit is
null
- See Also:
-
ban
@Nonnull @CheckReturnValue AuditableRestAction<BulkBanResponse> ban(@Nonnull Collection<? extends UserSnowflake> users, @Nullable Duration deletionTime) Bans up to 200 of the provided users.
To set a ban reason, useAuditableRestAction.reason(String)
.The
BulkBanResponse
includes a list offailed users
, which is populated with users that could not be banned, for instance due to some internal server error or permission issues. This list of failed users also includes all users that were already banned.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyFAILED_TO_BAN_USERS
None of the users could be banned
- Parameters:
users
- The users to bandeletionTime
- Delete recent messages of the given timeframe (for instance the last hour withDuration.ofHours(1)
)- Returns:
AuditableRestAction
- Type:BulkBanResponse
- Throws:
HierarchyException
- If any of the provided users is the guild owner or has a higher or equal role positionInsufficientPermissionException
- If the bot does not havePermission.BAN_MEMBERS
orPermission.MANAGE_SERVER
IllegalArgumentException
-- If the users collection is null or contains null
- If the deletionTime is negative
-
ban
@Nonnull @CheckReturnValue default AuditableRestAction<BulkBanResponse> ban(@Nonnull Collection<? extends UserSnowflake> users, int deletionTimeframe, @Nonnull TimeUnit unit) Bans up to 200 of the provided users.
To set a ban reason, useAuditableRestAction.reason(String)
.The
BulkBanResponse
includes a list offailed users
, which is populated with users that could not be banned, for instance due to some internal server error or permission issues. This list of failed users also includes all users that were already banned.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyFAILED_TO_BAN_USERS
None of the users could be banned
- Parameters:
users
- The users to bandeletionTimeframe
- The timeframe for the history of messages that will be deleted. (seconds precision)unit
- Timeframe unit as aTimeUnit
(for exampleban(user, 7, TimeUnit.DAYS)
).- Returns:
AuditableRestAction
- Type:BulkBanResponse
- Throws:
HierarchyException
- If any of the provided users is the guild owner or has a higher or equal role positionInsufficientPermissionException
- If the bot does not havePermission.BAN_MEMBERS
orPermission.MANAGE_SERVER
IllegalArgumentException
-- If null is provided
- If the deletionTimeframe is negative
-
unban
Unbans the specifiedUserSnowflake
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:
user
- TheUserSnowflake
to unban. This can be a member or user instance orUser.fromId(long)
.- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.BAN_MEMBERS
permission.IllegalArgumentException
- If the provided user is null
-
timeoutFor
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutFor(@Nonnull UserSnowflake user, 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:
user
- TheUserSnowflake
to timeout. This can be a member or user instance orUser.fromId(long)
.amount
- 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
user
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 UserSnowflake user, @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:
user
- TheUserSnowflake
to timeout. This can be a member or user instance orUser.fromId(long)
.duration
- 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
user
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 AuditableRestAction<Void> timeoutUntil(@Nonnull UserSnowflake user, @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:
user
- TheUserSnowflake
to timeout. This can be a member or user instance orUser.fromId(long)
.temporal
- The time the specified Member will be released from 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
user
is null - 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:
user
- TheUserSnowflake
to timeout. This can be a member or user instance orUser.fromId(long)
.- 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)
)
-
deafen
@Nonnull @CheckReturnValue AuditableRestAction<Void> deafen(@Nonnull UserSnowflake user, boolean deafen) Sets the Guild Deafened 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:
user
- TheUserSnowflake
who'sGuildVoiceState
to change. This can be a member or user instance orUser.fromId(long)
.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 user is null.IllegalStateException
- If the provided user is not currently connected to a voice channel.
-
mute
@Nonnull @CheckReturnValue AuditableRestAction<Void> mute(@Nonnull UserSnowflake user, boolean mute) Sets the Guild Muted 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:
user
- TheUserSnowflake
who'sGuildVoiceState
to change. This can be a member or user instance orUser.fromId(long)
.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 user is null.IllegalStateException
- If the provided user is not currently connected to a voice channel.
-
addRoleToMember
@Nonnull @CheckReturnValue AuditableRestAction<Void> addRoleToMember(@Nonnull UserSnowflake user, @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:
user
- TheUserSnowflake
to change roles for. This can be a member or user instance orUser.fromId(long)
.role
- The role which should be assigned atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified member or 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 AuditableRestAction<Void> removeRoleFromMember(@Nonnull UserSnowflake user, @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:
user
- TheUserSnowflake
to change roles for. This can be a member or user instance orUser.fromId(long)
.role
- The role which should be removed atomically- Returns:
AuditableRestAction
- Throws:
IllegalArgumentException
-- If the specified member or 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
-
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(UserSnowflake, Role)
andremoveRoleFromMember(UserSnowflake, 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
-
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 (up to 100 characters)- 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
, blank, or longer than 100 characters
-
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 create (up to 100 characters)parent
- 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
, blank, or longer than 100 characters; 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 (up to 100 characters)- 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
, blank, or longer than 100 characters
-
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 create (up to 100 characters)parent
- 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
, blank, or longer than 100 characters; 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 (up to 100 characters)- 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
, blank, or longer than 100 characters
-
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 create (up to 100 characters)parent
- 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
, blank, or longer than 100 characters; 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 (up to 100 characters)- 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
, blank, or longer than 100 characters
-
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 create (up to 100 characters)parent
- 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
, blank, or longer than 100 characters; or the provided parent is not in the same guild.
-
createForumChannel
@Nonnull @CheckReturnValue default ChannelAction<ForumChannel> createForumChannel(@Nonnull String name) Creates a newForumChannel
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 ForumChannel to create (up to 100 characters)- Returns:
- A specific
ChannelAction
This action allows to set fields for the new ForumChannel before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
, blank, or longer than 100 characters
-
createForumChannel
@Nonnull @CheckReturnValue ChannelAction<ForumChannel> createForumChannel(@Nonnull String name, @Nullable Category parent) Creates a newForumChannel
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 ForumChannel to create (up to 100 characters)parent
- The optional parent category for this channel, or null- Returns:
- A specific
ChannelAction
This action allows to set fields for the new ForumChannel before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
, blank, or longer than 100 characters; or the provided parent is not in the same guild.
-
createMediaChannel
@Nonnull @CheckReturnValue default ChannelAction<MediaChannel> createMediaChannel(@Nonnull String name) Creates a newMediaChannel
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 MediaChannel to create (up to 100 characters)- Returns:
- A specific
ChannelAction
This action allows to set fields for the new MediaChannel before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
, blank, or longer than 100 characters
-
createMediaChannel
@Nonnull @CheckReturnValue ChannelAction<MediaChannel> createMediaChannel(@Nonnull String name, @Nullable Category parent) Creates a newMediaChannel
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 MediaChannel to create (up to 100 characters)parent
- The optional parent category for this channel, or null- Returns:
- A specific
ChannelAction
This action allows to set fields for the new MediaChannel before creating it - Throws:
InsufficientPermissionException
- If the logged in account does not have thePermission.MANAGE_CHANNEL
permissionIllegalArgumentException
- If the provided name isnull
, blank, or longer than 100 characters; 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 (up to 100 characters)- 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
, blank, or longer than 100 characters
-
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
-
createEmoji
@Nonnull @CheckReturnValue AuditableRestAction<RichCustomEmoji> createEmoji(@Nonnull String name, @Nonnull Icon icon, @Nonnull Role... roles) Creates a newRichCustomEmoji
in this Guild.
If one or more Roles are specified the new emoji will only be available to Members with any of the specified Roles (seeMember.canInteract(RichCustomEmoji)
)
For this to be successful, the logged in account has to have theMANAGE_GUILD_EXPRESSIONS
Permission.Unicode emojis are not included as
RichCustomEmoji
!Note that a guild is limited to 50 normal and 50 animated emojis by default. Some guilds are able to add additional emojis 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 emoji could not be created due to a permission discrepancy
- Parameters:
name
- The name for the new emojiicon
- TheIcon
for the new emojiroles
- TheRoles
the new emoji should be restricted to
If no roles are provided the emoji will be available to all Members of this Guild- Returns:
AuditableRestAction
- Type:RichCustomEmoji
- Throws:
InsufficientPermissionException
- If the logged in account does not have theMANAGE_GUILD_EXPRESSIONS
Permission
-
createSticker
@Nonnull @CheckReturnValue AuditableRestAction<GuildSticker> createSticker(@Nonnull String name, @Nonnull String description, @Nonnull FileUpload file, @Nonnull Collection<String> tags) Creates a newGuildSticker
in this Guild.Possible
ErrorResponses
include:INVALID_FILE_UPLOADED
The sticker file asset is not in a supported file formatMISSING_PERMISSIONS
The sticker could not be created due to a permission discrepancy
- Parameters:
name
- The sticker name (2-30 characters)description
- The sticker description (2-100 characters, or empty)file
- The sticker file containing the asset (png/apng/gif/lottie) with valid file extension (png, gif, or json)tags
- The tags to use for auto-suggestions (Up to 200 characters in total)- Returns:
AuditableRestAction
- Type:GuildSticker
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_GUILD_EXPRESSIONS
permissionIllegalArgumentException
-- If the name is not between 2 and 30 characters long
- If the description is more than 100 characters long or exactly 1 character long
- If the asset file is null or of an invalid format (must be PNG, GIF, or LOTTIE)
- If anything is
null
-
createSticker
@Nonnull @CheckReturnValue default AuditableRestAction<GuildSticker> createSticker(@Nonnull String name, @Nonnull String description, @Nonnull FileUpload file, @Nonnull String tag, @Nonnull String... tags) Creates a newGuildSticker
in this Guild.Possible
ErrorResponses
include:INVALID_FILE_UPLOADED
The sticker file asset is not in a supported file formatMISSING_PERMISSIONS
The sticker could not be created due to a permission discrepancy
- Parameters:
name
- The sticker name (2-30 characters)description
- The sticker description (2-100 characters, or empty)file
- The sticker file containing the asset (png/apng/gif/lottie) with valid file extension (png, gif, or json)tag
- The sticker tag used for suggestions (emoji or tag words)tags
- Additional tags to use for suggestions- Returns:
AuditableRestAction
- Type:GuildSticker
- Throws:
InsufficientPermissionException
- If the currently logged in account does not have theMANAGE_GUILD_EXPRESSIONS
permissionIllegalArgumentException
-- If the name is not between 2 and 30 characters long
- If the description is more than 100 characters long or exactly 1 character long
- If the asset file is null or of an invalid format (must be PNG, GIF, or LOTTIE)
- If anything is
null
-
deleteSticker
Deletes a sticker from the guild.The returned
RestAction
can encounter the following Discord errors:UNKNOWN_STICKER
Occurs when the provided id does not refer to a sticker known by Discord.
- Returns:
AuditableRestAction
- Throws:
IllegalStateException
- If null is providedInsufficientPermissionException
- If the currently logged in account does not haveMANAGE_GUILD_EXPRESSIONS
in the guild.
-
createScheduledEvent
@Nonnull @CheckReturnValue ScheduledEventAction createScheduledEvent(@Nonnull String name, @Nonnull String location, @Nonnull OffsetDateTime startTime, @Nonnull OffsetDateTime endTime) Creates a newScheduledEvent
. Events created with this method will be ofType.EXTERNAL
. These events are set to take place at an external location.Requirements
Events are required to have a name, location and start time. Additionally, an end time must also be specified for events ofType.EXTERNAL
.Permission.MANAGE_EVENTS
is required on the guild level in order to create this type of event.Example
guild.createScheduledEvent("Cactus Beauty Contest", "Mike's Backyard", OffsetDateTime.now().plusHours(1), OffsetDateTime.now().plusHours(3)) .setDescription("Come and have your cacti judged! _Must be spikey to enter_") .queue();
- Parameters:
name
- the name for this scheduled event, 1-100 characterslocation
- the external location for this scheduled event, 1-100 charactersstartTime
- the start time for this scheduled event, can't be in the past or after the end timeendTime
- the end time for this scheduled event, has to be later than the start time- Returns:
ScheduledEventAction
- Throws:
IllegalArgumentException
-- If a required parameter is
null
or empty - If the start time is in the past
- If the end time is before the start time
- If the name is longer than 100 characters
- If the description is longer than 1000 characters
- If the location is longer than 100 characters
- If a required parameter is
-
createScheduledEvent
@Nonnull @CheckReturnValue ScheduledEventAction createScheduledEvent(@Nonnull String name, @Nonnull GuildChannel channel, @Nonnull OffsetDateTime startTime) Creates a newScheduledEvent
.Requirements
Events are required to have a name, channel and start time. Depending on the type of channel provided, an event will be of one of two differentTypes
:-
Type.STAGE_INSTANCE
These events are set to take place inside of aStageChannel
. The following permissions are required in the specified stage channel in order to create an event there: -
Type.VOICE
These events are set to take place inside of aVoiceChannel
. The following permissions are required in the specified voice channel in order to create an event there:
Example
guild.createScheduledEvent("Cactus Beauty Contest", guild.getGuildChannelById(channelId), OffsetDateTime.now().plusHours(1)) .setDescription("Come and have your cacti judged! _Must be spikey to enter_") .queue();
- Parameters:
name
- the name for this scheduled event, 1-100 characterschannel
- the voice or stage channel where this scheduled event will take placestartTime
- the start time for this scheduled event, can't be in the past- Returns:
ScheduledEventAction
- Throws:
IllegalArgumentException
-- If a required parameter is
null
or empty - If the start time is in the past
- If the name is longer than 100 characters
- If the description is longer than 1000 characters
- If the channel is not a Stage or Voice channel
- If the channel is not from the same guild as the scheduled event
- If a required parameter is
-
-
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.You can also move roles to a position relative to another role, by using
moveBelow(...)
andmoveAbove(...)
.This uses descending ordering which means the highest role is first!
This means the lowest role appears at indexn - 1
and the highest role at index0
.
Providingtrue
tomodifyRolePositions(boolean)
will result in the ordering being in ascending order, with the highest role at indexn - 1
and the lowest at index0
.
As a note:Member.getRoles()
andGuild.getRoles()
are both in descending order, just like this method.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
-
modifyWelcomeScreen
TheManager
for this guild's welcome screen, used to modify properties of the welcome screen like if the welcome screen is enabled, the description and welcome channels.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The GuildWelcomeScreenManager for this guild's welcome screen
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_SERVER
-
kick(UserSnowflake)
andAuditableRestAction.reason(String)
instead.