Interface Guild
- All Superinterfaces:
IDetachableEntity,IGuildChannelContainer<GuildChannel>,ISnowflake
Guild.
This should contain all information provided from Discord about a Guild.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classRepresents a Ban object.static enumThe boost tier for this guild.static enumThe Explicit-Content-Filter Level of a Guild.static classMeta-Data for a Guildstatic enumRepresents the Multifactor Authentication level required by the Guild.static enumRepresents the Notification-level of the Guild.static enumRepresents the NSFW level for this guild.static enumRepresents the idle time allowed until a user is moved to the AFKVoiceChannelif one is set (Guild.getAfkChannel()).static enumRepresents the Verification-Level of the Guild. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTemplate forgetBannerUrl().static final StringTemplate forgetIconUrl().static final StringTemplate 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 providedUserSnowflakeand deletes messages sent by the user based on thedeletionTimeframe.Cancels theRequest-to-Speak.Creates a newAutoModRulefor this guild.createCategory(String name) Creates a newCategoryin this Guild.default <T extends ICopyableChannel>
ChannelAction<T> createCopyOfChannel(T channel) Creates a copy of the specifiedGuildChannelin thisGuild.default RoleActioncreateCopyOfRole(Role role) createEmoji(String name, Icon icon, Role... roles) Creates a newRichCustomEmojiin this Guild.default ChannelAction<ForumChannel> createForumChannel(String name) Creates a newForumChannelin this Guild.createForumChannel(String name, Category parent) Creates a newForumChannelin this Guild.default ChannelAction<MediaChannel> createMediaChannel(String name) Creates a newMediaChannelin this Guild.createMediaChannel(String name, Category parent) Creates a newMediaChannelin this Guild.default ChannelAction<NewsChannel> createNewsChannel(String name) Creates a newNewsChannelin this Guild.createNewsChannel(String name, Category parent) Creates a newNewsChannelin this Guild.Creates a newRolein 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 newStageChannelin this Guild.createStageChannel(String name, Category parent) Creates a newStageChannelin this Guild.default AuditableRestAction<GuildSticker> createSticker(String name, String description, FileUpload file, String tag, String... tags) Creates a newGuildStickerin this Guild.createSticker(String name, String description, FileUpload file, Collection<String> tags) Creates a newGuildStickerin this Guild.createTemplate(String name, String description) Used to create a newTemplatefor this Guild.default ChannelAction<TextChannel> createTextChannel(String name) Creates a newTextChannelin this Guild.createTextChannel(String name, Category parent) Creates a newTextChannelin this Guild.default ChannelAction<VoiceChannel> createVoiceChannel(String name) Creates a newVoiceChannelin this Guild.createVoiceChannel(String name, Category parent) Creates a newVoiceChannelin this Guild.deafen(UserSnowflake user, boolean deafen) Sets the Guild Deafened state of theMemberbased on the provided boolean.default AuditableRestAction<Void> deleteAutoModRuleById(long id) Deletes theAutoModRulefor the provided id.Deletes theAutoModRulefor 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 CommandEditActioneditCommandById(Command.Type type, long id) Edit an existing command by id.editCommandById(Command.Type type, String 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 theVoiceChannelthat has been set as the channel whichMemberswill be moved to after they have been inactive in aVoiceChannelfor longer thangetAfkTimeout().TheTimeoutset for this Guild representing the amount of time that must pass for a Member to have had no activity in aVoiceChannelto be considered AFK.TheAudioManagerthat represents the audio connection for this Guild.default ImageProxyReturns anImageProxyfor this guild's banner image.The guild banner id.default StringThe guild banner url.intThe amount of boosts this server currently has.Sorted list ofMembersthat boost this guild.default RoleLooks up the role which is the booster role of this guild.The boost tier for this guild.default RoleLooks up the role which is the integration role for the currently connected bot (self-user).SortedSnowflakeCacheViewofCategory.default @Unmodifiable List<GuildChannel> Populated list ofchannelsfor this guild.@Unmodifiable List<GuildChannel> getChannels(boolean includeHidden) Populated list ofchannelsfor this guild.Provides theTextChannelthat receives community updates.The defaultStandardGuildChannelfor aGuild.Returns the default message Notification-Level of this Guild.The description for this guild.default RichCustomEmojigetEmojiById(long id) Gets anRichCustomEmojifrom this guild that has the same id as the one provided.default RichCustomEmojigetEmojiById(String id) Gets aRichCustomEmojifrom this guild that has the same id as the one provided.SnowflakeCacheViewof all cachedCustom Emojisof this Guild.default @Unmodifiable List<RichCustomEmoji> Gets allCustom Emojisbelonging to thisGuild.default @Unmodifiable List<RichCustomEmoji> getEmojisByName(String name, boolean ignoreCase) Gets a list of allCustom Emojisin 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 ImageProxygetIcon()Returns anImageProxyfor this guild's icon.The Discord hash-id of theGuildicon image.default StringThe URL of theGuildicon image.getJDA()Returns theJDAinstance of this GuildThe preferred locale for this guild.Returns theGuildManagerfor this Guild, used to modify all properties and settings of the Guild.default intThe maximum bitrate that can be applied to a voice channel in this guild.default intThe maximum amount of custom emojis a guild can have based on the guilds boost tier.default longReturns the maximum size for files that can be uploaded to this Guild.intThe maximum amount of members that can join this guild.intThe maximum amount of connected members this guild can have at a time.getMember(UserSnowflake user) Gets the Guild specificMemberobject for the providedUserSnowflake.default MembergetMemberById(long userId) Gets aMemberobject via the id of the user.default MembergetMemberById(String userId) Gets aMemberobject via the id of the user.default MembergetMemberByTag(String tag) Searches for aMemberthat has the matching Discord Tag.default MembergetMemberByTag(String username, String discriminator) Searches for aMemberthat has the matching Discord Tag.MemberCacheViewfor all cachedMembersof this Guild.intThe expected member count for this guild.A list of allMembersin this Guild.getMembersByEffectiveName(String name, boolean ignoreCase) Gets a list of allMemberswho have the same effective name as the one provided.getMembersByName(String name, boolean ignoreCase) Gets a list of allMemberswho have the same name as the one provided.getMembersByNickname(String nickname, boolean ignoreCase) Gets a list of allMemberswho have the same nickname as the one provided.getMembersWithRoles(Collection<Role> roles) getMembersWithRoles(Role... roles) getName()The human readable name of theGuild.SortedSnowflakeCacheViewofNewsChannel.Returns the NSFW Level that this guild is classified with.getOwner()TheMemberobject for the owner of this Guild.default StringThe ID for the current owner of this guild.longThe ID for the current owner of this guild.Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.default RolegetRoleByBot(long userId) Looks up a role which is the integration role for a bot.default RolegetRoleByBot(String userId) Looks up a role which is the integration role for a bot.default RolegetRoleByBot(User user) Looks up a role which is the integration role for a bot.default RolegetRoleById(long id) Gets aRolefrom this guild that has the same id as the one provided.default RolegetRoleById(String id) Gets aRolefrom this guild that has the same id as the one provided.SortedSnowflakeCacheViewof all cachedRolesof this Guild.getRoles()getRolesByName(String name, boolean ignoreCase) Gets a list of allRolesin this Guild that have the same name as the one provided.Provides theTextChannelthat lists the rules of the guild.Provides theTextChannelthat receives discord safety alerts.default ScheduledEventgetScheduledEventById(long id) Gets aScheduledEventfrom this guild that has the same id as the one provided.default ScheduledEventGets aScheduledEventfrom this guild that has the same id as the one provided.SortedSnowflakeCacheViewof all cachedScheduledEventsof this Guild.default @Unmodifiable List<ScheduledEvent> Gets allScheduledEventsin this guild.default @Unmodifiable List<ScheduledEvent> getScheduledEventsByName(String name, boolean ignoreCase) Gets a list of allScheduledEventsin this Guild that have the same name as the one provided.The current guildsecurity incident actions.The current security incident detections.Gets theMemberobject of the currently logged in account in this guild.default ImageProxyReturns anImageProxyfor this guild's splash icon.The Discord hash-id of the splash image for this Guild.default StringThe URL of the splash image for this Guild.SortedSnowflakeCacheViewofStageChannel.default GuildStickergetStickerById(long id) Gets aGuildStickerfrom this guild that has the same id as the one provided.default GuildStickergetStickerById(String id) Gets aGuildStickerfrom this guild that has the same id as the one provided.SnowflakeCacheViewof all cachedGuildStickersof this Guild.default @Unmodifiable List<GuildSticker> Gets all customGuildStickersbelonging to thisGuild.default @Unmodifiable List<GuildSticker> getStickersByName(String name, boolean ignoreCase) Gets a list of allGuildStickersin this Guild that have the same name as the one provided.Provides theTextChannelthat has been set as the channel which newly joinedMemberswill be announced in.SortedSnowflakeCacheViewofTextChannel.The vanity url code for this Guild.default StringThe vanity url for this Guild.Returns the verification-Level of this Guild.SortedSnowflakeCacheViewofVoiceChannel.@Unmodifiable List<GuildVoiceState> A list containing the cachedGuildVoiceStateof everyMemberconnected to an audio channel in this guild.booleanReturns whether this Guild has its boost progress bar shown.default booleanWhether the invites for this guild are paused/disabled.booleanisLoaded()Whether this guild has loaded members.booleanisMember(UserSnowflake user) Used to determine if the providedUserSnowflakeis a member of this Guild.kick(UserSnowflake user) default RestAction<Void> kickVoiceMember(UserSnowflake user) Used to kick a member 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 AutoModRuleManagermodifyAutoModRuleById(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 specificRestActionextension to allow moving Channelsup/downortoa 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 RoleOrderActionModifies the positional order ofGuild.getRoles()using a specificRestActionextension to allow moving Rolesup/downortoa specific position.modifyRolePositions(boolean useAscendingOrder) Modifies the positional order ofGuild.getRoles()using a specificRestActionextension to allow moving Rolesup/downortoa specific position.modifySecurityIncidents(SecurityIncidentActions incidents) Update the current guildsecurity incident actions.Modifies the positional order ofGuild.getTextChannels()using a specificRestActionextension to allow moving Channelsup/downortoa specific position.modifyTextChannelPositions(Category category) Modifies the positional order ofCategory#getTextChannels()using an extension ofChannelOrderActionspecialized for ordering the nestedTextChannelsof thisCategory.Modifies the positional order ofGuild.getVoiceChannels()using a specificRestActionextension to allow moving Channelsup/downortoa specific position.modifyVoiceChannelPositions(Category category) Modifies the positional order ofCategory#getVoiceChannels()using an extension ofChannelOrderActionspecialized for ordering the nestedVoiceChannelsof thisCategory.TheManagerfor 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(UserSnowflake user, AudioChannel audioChannel) Used to move a Member from oneAudioChannelto anotherAudioChannel.mute(UserSnowflake user, boolean mute) Sets the Guild Muted state of theMemberbased 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.voidRe-apply theMemberCachePolicyof this session to allMembersof 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 theAutoModRulefor the provided id.Retrieves theAutoModRulefor the provided id.RestAction<@Unmodifiable List<AutoModRule>> Retrieves all currentAutoModRulesfor this guild.retrieveBan(UserSnowflake user) Retrieves aBanof the providedUserSnowflake.Retrieves an immutable list of the currently bannedUsers.default RestAction<Command> retrieveCommandById(long id) Retrieves the existingCommandinstance by id.Retrieves the existingCommandinstance by id.Retrieves theIntegrationPrivilegesfor 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 theIntegrationPrivilegesfor the target with the specified ID.retrieveIntegrationPrivilegesById(String targetId) Retrieves theIntegrationPrivilegesfor the target with the specified ID.RestAction<@Unmodifiable List<Invite>> Retrieves allInvitesfor 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.default RestAction<GuildVoiceState> Load the member's voice state for the specifiedUserSnowflake.retrieveMemberVoiceStateById(long id) Load the member's voice state for the specified user.default RestAction<GuildVoiceState> Load the member's voice state for the specified user.LoadsGuild.MetaDatafor 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 aScheduledEventby its ID.Retrieves aScheduledEventby its ID.default RestAction<List<ScheduledEvent>> Retrieves allScheduledEventsfor this guild.retrieveScheduledEvents(boolean includeUserCount) Retrieves allScheduledEventsfor this guild.retrieveSticker(StickerSnowflake sticker) Attempts to retrieve aGuildStickerobject 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 allTemplatesfor this guild.Retrieves the Vanity Invite meta data for this guild.RestAction<@Unmodifiable List<Webhook>> Retrieves allWebhooksfor this Guild.Retrieves thewelcome screenfor this Guild.default AuditableRestAction<Void> timeoutFor(UserSnowflake user, long amount, TimeUnit unit) Puts the specified Member in time out in thisGuildfor a specific amount of time.default AuditableRestAction<Void> timeoutFor(UserSnowflake user, Duration duration) Puts the specified Member in time out in thisGuildfor a specific amount of time.timeoutUntil(UserSnowflake user, TemporalAccessor temporal) Puts the specified Member in time out in thisGuilduntil the specified date.unban(UserSnowflake user) Unbans the specifiedUserSnowflakefrom this Guild.booleanunloadMember(long userId) Attempts to remove the user with the provided id from the member cache.Configures the complete list of guild commands.default CommandCreateActionupsertCommand(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.detached.IDetachableEntity
isDetachedMethods 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, getVoiceChannelsByNameMethods 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:ListofCommand- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveCommands
Retrieves the list of guild commands.
This list does not include global commands! UseJDA.retrieveCommands()for global commands.- Parameters:
withLocalizations-trueif the localization data (such as name and description) should be included- Returns:
RestAction- Type:ListofCommand- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveCommandById
Retrieves the existingCommandinstance 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:
DetachedEntityException- If this entity isdetachedIllegalArgumentException- If the provided id is not a valid snowflake
-
retrieveCommandById
Retrieves the existingCommandinstance 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:
DetachedEntityException- If this entity isdetached
-
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- TheCommandDatafor the command- Returns:
RestAction- Type:Command
The RestAction used to create or update the command- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this entity isdetached- 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 requirementsDetachedEntityException- If this entity isdetached
-
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- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
editCommandById
@Nonnull @CheckReturnValue CommandEditAction editCommandById(@Nonnull Command.Type type, @Nonnull String id) Edit an existing command by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND- Parameters:
type- The command typeid- The id of the command to edit- Returns:
CommandEditActionused to edit the command- Throws:
IllegalArgumentException- If the provided id is not a valid snowflake or the type isCommand.Type.UNKNOWNDetachedEntityException- If this entity isdetached
-
editCommandById
@Nonnull @CheckReturnValue default CommandEditAction editCommandById(@Nonnull Command.Type type, long id) Edit an existing command by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND- Parameters:
type- The command typeid- The id of the command to edit- Returns:
CommandEditActionused to edit the command- Throws:
IllegalArgumentException- If the type isCommand.Type.UNKNOWNDetachedEntityException- If this entity isdetached
-
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 snowflakeDetachedEntityException- If this entity isdetached
-
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:
DetachedEntityException- If this entity isdetached
-
retrieveIntegrationPrivilegesById
@Nonnull @CheckReturnValue RestAction<List<IntegrationPrivilege>> retrieveIntegrationPrivilegesById(@Nonnull String targetId) Retrieves theIntegrationPrivilegesfor 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:ListofIntegrationPrivilege- Throws:
IllegalArgumentException- If the id is not a valid snowflakeDetachedEntityException- If this entity isdetached
-
retrieveIntegrationPrivilegesById
@Nonnull @CheckReturnValue default RestAction<List<IntegrationPrivilege>> retrieveIntegrationPrivilegesById(long targetId) Retrieves theIntegrationPrivilegesfor 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:ListofIntegrationPrivilege- Throws:
IllegalArgumentException- If the id is not a valid snowflakeDetachedEntityException- If this entity isdetached
-
retrieveCommandPrivileges
Retrieves theIntegrationPrivilegesfor the commands in this guild.
The RestAction provides aPrivilegeConfigproviding the privileges of this application and its commands.Moderators of a guild can modify these privileges through the Integrations Menu
- Returns:
RestAction- Type:PrivilegeConfig- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveRegions
Retrieves the available regions for this Guild
Shortcut forretrieveRegions(true)
This will include deprecated voice regions by default.- Returns:
RestAction- TypeEnumSet- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveRegions
Retrieves the available regions for this Guild- Parameters:
includeDeprecated- Whether to include deprecated regions- Returns:
RestAction- TypeEnumSet- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveAutoModRules
Retrieves all currentAutoModRulesfor this guild.- Returns:
RestAction- Type:ListofAutoModRule- Throws:
InsufficientPermissionException- If the currently logged in account does not have theMANAGE_SERVERpermissionDetachedEntityException- If this entity isdetached
-
retrieveAutoModRuleById
Retrieves theAutoModRulefor 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_SERVERpermissionDetachedEntityException- If this entity isdetached
-
retrieveAutoModRuleById
Retrieves theAutoModRulefor 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_SERVERpermissionDetachedEntityException- If this entity isdetached
-
createAutoModRule
@Nonnull @CheckReturnValue AuditableRestAction<AutoModRule> createAutoModRule(@Nonnull AutoModRuleData data) Creates a newAutoModRulefor 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 permissionsIllegalStateException-- If the provided data does not have any
AutoModResponseconfigured - If any of the configured
AutoModResponsesis not supported by theAutoModTriggerType
- If the provided data does not have any
DetachedEntityException- If this entity isdetached
-
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_SERVERpermission.DetachedEntityException- If this entity isdetached
-
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_SERVERpermission.DetachedEntityException- If this entity isdetached
-
deleteAutoModRuleById
Deletes theAutoModRulefor 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_SERVERpermissionDetachedEntityException- If this entity isdetached
-
deleteAutoModRuleById
Deletes theAutoModRulefor 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_SERVERpermissionDetachedEntityException- If this entity isdetached
-
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- TheUserSnowflakefor 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_INVITEDetachedEntityException- If this entity isdetached- Since:
- 3.7.0
- See Also:
-
isLoaded
boolean isLoaded()Whether this guild has loaded members.
This will always be false if theGUILD_MEMBERSintent is disabled.- Returns:
- True, if members are loaded.
- Throws:
DetachedEntityException- If this entity isdetached
-
pruneMemberCache
void pruneMemberCache()Re-apply theMemberCachePolicyof this session to allMembersof 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 }- Throws:
DetachedEntityException- If this entity isdetached- 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 theSelfUserthis will simply returnfalse.This should be used by an implementation of
MemberCachePolicyas 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
- Throws:
DetachedEntityException- If this entity isdetached- 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_MEMBERSis disabled, this will not be updated.- Returns:
- The expected member count for this guild
- Throws:
DetachedEntityException- If this entity isdetached
-
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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getIconId
The Discord hash-id of theGuildicon 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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getIconUrl
The URL of theGuildicon 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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getIcon
Returns anImageProxyfor this guild's icon.- Returns:
- The
ImageProxyof this guild's icon - Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached
-
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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getSplash
Returns anImageProxyfor this guild's splash icon.- Returns:
- Possibly-null
ImageProxyof this guild's splash icon - Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- 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_SERVERpermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_SERVERDetachedEntityException- If this entity isdetached- Since:
- 4.2.1
-
getDescription
The description for this guild.
This is displayed in the server browser below the guild name for verified guilds, and in embedded invite links.The description can be modified using
GuildManager.setDescription(String).- Returns:
- The description
- Throws:
DetachedEntityException- If this entity isdetached- 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
DiscordLocalefor 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
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- Since:
- 4.0.0
-
getBanner
Returns anImageProxyfor this guild's banner image.- Returns:
- Possibly-null
ImageProxyof this guild's banner image - Throws:
DetachedEntityException- If this entity isdetached- 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.
- Throws:
DetachedEntityException- If this entity isdetached- Since:
- 4.0.0
-
getBoostCount
int getBoostCount()The amount of boosts this server currently has.- Returns:
- The boost count
- Throws:
DetachedEntityException- If this entity isdetached- Since:
- 4.0.0
-
getBoosters
Sorted list ofMembersthat 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
- Throws:
DetachedEntityException- If this entity isdetached
-
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
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached
-
getMaxMembers
int getMaxMembers()The maximum amount of members that can join this guild.- Returns:
- The maximum amount of members
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- Since:
- 4.0.0
- See Also:
-
retrieveMetaData
LoadsGuild.MetaDatafor this guild instance.- Returns:
RestAction- Type:Guild.MetaData- Throws:
DetachedEntityException- If this entity isdetached- Since:
- 4.2.0
-
getAfkChannel
Provides theVoiceChannelthat has been set as the channel whichMemberswill be moved to after they have been inactive in aVoiceChannelfor 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
VoiceChannelthat is the AFK Channel. - Throws:
DetachedEntityException- If this entity isdetached
-
getSystemChannel
Provides theTextChannelthat has been set as the channel which newly joinedMemberswill 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
TextChannelthat is the system Channel. - Throws:
DetachedEntityException- If this entity isdetached
-
getRulesChannel
Provides theTextChannelthat lists the rules of the guild.
If this guild doesn't have the COMMUNITYfeature, this returnsnull.- Returns:
- Possibly-null
TextChannelthat is the rules channel - Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getCommunityUpdatesChannel
Provides theTextChannelthat receives community updates.
If this guild doesn't have the COMMUNITYfeature, this returnsnull.- Returns:
- Possibly-null
TextChannelthat is the community updates channel - Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getSafetyAlertsChannel
Provides theTextChannelthat receives discord safety alerts.
If this guild doesn't have the COMMUNITYfeature, this returnsnull.- Returns:
- Possibly-null
TextChannelthat is the saferty alerts channel. - See Also:
-
getOwner
TheMemberobject 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.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.
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- 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
- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getAfkTimeout
TheTimeoutset for this Guild representing the amount of time that must pass for a Member to have had no activity in aVoiceChannelto 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
Timeoutset for this Guild. - Throws:
DetachedEntityException- If this entity isdetached
-
getSecurityIncidentActions
The current guildsecurity incident actions.
Security incident actions are used to temporarily disable features for the purpose of moderation.- Returns:
SecurityIncidentActionsthe current actions- Throws:
DetachedEntityException- If this entity isdetached
-
getSecurityIncidentDetections
The current security incident detections.
Discord may automatically detect spammers or raiders.- Returns:
SecurityIncidentDetectionsthe current detections- Throws:
DetachedEntityException- If this entity isdetached
-
isMember
Used to determine if the providedUserSnowflakeis 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
- Throws:
DetachedEntityException- If this entity isdetached
-
getSelfMember
Gets theMemberobject 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.
- Throws:
DetachedEntityException- If this entity isdetached
-
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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getMember
Gets the Guild specificMemberobject for the providedUserSnowflake.
If the user is not in this guild or currently uncached,nullis returned.This will only check cached members!
- Parameters:
user- TheUserSnowflakefor the member to get. This can be a member or user instance orUser.fromId(long).- Returns:
- Possibly-null
Memberfor the relatedUser. - Throws:
IllegalArgumentException- If the provided user is nullDetachedEntityException- If this entity isdetached- See Also:
-
getMemberById
Gets aMemberobject 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 theuserIdprovided, 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
Memberwith the relateduserId. - Throws:
NumberFormatException- If the providedidcannot be parsed byLong.parseLong(String)DetachedEntityException- If this entity isdetached- See Also:
-
getMemberById
Gets aMemberobject 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 theuserIdprovided, 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
Memberwith the relateduserId. - Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getMemberByTag
Searches for aMemberthat has the matching Discord Tag.
Format has to be in the formUsername#Discriminatorwhere 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 thenicknameof the member but the username.This will only check cached members!
SeeMemberCachePolicyThis only checks users that are in this guild. If a user exists with the tag that is not available in the
Member-Cacheit 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
Memberfor 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 formatDetachedEntityException- If this entity isdetached- See Also:
-
getMemberByTag
Searches for aMemberthat has the matching Discord Tag.
Format has to be in the formUsername#Discriminatorwhere 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 thenicknameof the member but the username.This will only check cached members!
SeeMemberCachePolicyThis only checks users that are in this guild. If a user exists with the tag that is not available in the
Member-Cacheit 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
Memberfor 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 formatDetachedEntityException- If this entity isdetached- See Also:
-
getMembers
A list of allMembersin this Guild.
The Members are not provided in any particular order.This will only check cached members!
SeeMemberCachePolicyThis 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.
- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getMembersByName
@Nonnull @Incubating default @Unmodifiable List<Member> getMembersByName(@Nonnull String name, boolean ignoreCase) Gets a list of allMemberswho have the same name as the one provided.
This compares againstMember.getUser().getName()
If there are noMemberswith 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 nullDetachedEntityException- If this entity isdetached- 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 allMemberswho 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 noMemberswith 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.
- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getMembersByEffectiveName
@Nonnull default @Unmodifiable List<Member> getMembersByEffectiveName(@Nonnull String name, boolean ignoreCase) Gets a list of allMemberswho have the same effective name as the one provided.
This compares againstMember.getEffectiveName().
If there are noMemberswith 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 nullDetachedEntityException- If this entity isdetached- See Also:
-
getMembersWithRoles
Gets a list ofMembersthat have allRolesprovided.
If there are noMemberswith all provided roles, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy- Parameters:
roles- TheRolesthat aMembermust have to be included in the returned list.- Returns:
- Possibly-empty immutable list of Members with all provided Roles.
- Throws:
IllegalArgumentException- If a providedRoleis from a different guild or null.DetachedEntityException- If this entity isdetached- See Also:
-
getMembersWithRoles
Gets a list ofMembersthat have all providedRoles.
If there are noMemberswith all provided roles, then this returns an empty list.This will only check cached members!
SeeMemberCachePolicy- Parameters:
roles- TheRolesthat aMembermust have to be included in the returned list.- Returns:
- Possibly-empty immutable list of Members with all provided Roles.
- Throws:
IllegalArgumentException- If a providedRoleis from a different guild or null.DetachedEntityException- If this entity isdetached- See Also:
-
getMemberCache
MemberCacheViewfor all cachedMembersof this Guild.This will only provide cached members!
SeeMemberCachePolicy- Returns:
MemberCacheView- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getScheduledEventCache
SortedSnowflakeCacheViewof all cachedScheduledEventsof 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_EVENTSto be enabled.- Returns:
SortedSnowflakeCacheView- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveScheduledEvents
Retrieves allScheduledEventsfor this guild.
This list does not include user count data. UseretrieveScheduledEvents(boolean)to get user count data- Returns:
RestAction- Type:ListofScheduledEvent- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveScheduledEvents
@Nonnull @CheckReturnValue RestAction<List<ScheduledEvent>> retrieveScheduledEvents(boolean includeUserCount) Retrieves allScheduledEventsfor this guild.- Parameters:
includeUserCount- Whether to include user counts for theScheduledEvents.- Returns:
RestAction- Type:ListofScheduledEvent- Throws:
DetachedEntityException- If this entity isdetached
-
getScheduledEventsByName
@Nonnull default @Unmodifiable List<ScheduledEvent> getScheduledEventsByName(@Nonnull String name, boolean ignoreCase) Gets a list of allScheduledEventsin this Guild that have the same name as the one provided.
If there are noScheduledEventswith the provided name, then this returns an empty list.This requires
CacheFlag.SCHEDULED_EVENTSto be enabled.- Parameters:
name- The name used to filter the returnedScheduledEventobjects.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 ornullDetachedEntityException- If this entity isdetached
-
getScheduledEventById
Gets aScheduledEventfrom 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 noScheduledEventwith an id that matches the provided one, then this returnsnull.This requires
CacheFlag.SCHEDULED_EVENTSto be enabled.- Parameters:
id- The id of theScheduledEvent.- Returns:
- Possibly-null
ScheduledEventwith matching id. - Throws:
NumberFormatException- If the providedidcannot be parsed byLong.parseLong(String)DetachedEntityException- If this entity isdetached
-
getScheduledEventById
Gets aScheduledEventfrom 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 noScheduledEventwith an id that matches the provided one, then this returnsnull.This requires
CacheFlag.SCHEDULED_EVENTSto be enabled.- Parameters:
id- The id of theScheduledEvent.- Returns:
- Possibly-null
ScheduledEventwith matching id. - Throws:
DetachedEntityException- If this entity isdetached
-
getScheduledEvents
Gets allScheduledEventsin 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_EVENTSto be enabled.- Returns:
- Possibly-empty immutable List of
ScheduledEvents. - Throws:
DetachedEntityException- If this entity isdetached
-
getStageChannelCache
Description copied from interface:IGuildChannelContainerSortedSnowflakeCacheViewofStageChannel.
InGuildcache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getStageChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SortedSnowflakeCacheView
-
getThreadChannelCache
Description copied from interface:IGuildChannelContainerSnowflakeCacheViewofThreadChannel.These threads can also represent posts in
ForumChannels.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getThreadChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SnowflakeCacheView
-
getCategoryCache
Description copied from interface:IGuildChannelContainerSortedSnowflakeCacheViewofCategory.
InGuildcache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getCategoryCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SortedSnowflakeCacheView
-
getTextChannelCache
Description copied from interface:IGuildChannelContainerSortedSnowflakeCacheViewofTextChannel.
InGuildcache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getTextChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SortedSnowflakeCacheView
-
getNewsChannelCache
Description copied from interface:IGuildChannelContainerSortedSnowflakeCacheViewofNewsChannel.
InGuildcache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getNewsChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SortedSnowflakeCacheView
-
getVoiceChannelCache
Description copied from interface:IGuildChannelContainerSortedSnowflakeCacheViewofVoiceChannel.
InGuildcache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getVoiceChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SortedSnowflakeCacheView
-
getForumChannelCache
Description copied from interface:IGuildChannelContainerSnowflakeCacheViewofForumChannel.This getter exists on any instance of
IGuildChannelContainerand 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 onJDAorShardManager, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDAinstance, you can useJDA.awaitReady().- Specified by:
getForumChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SnowflakeCacheView
-
getChannelCache
SortedChannelCacheViewofGuildChannel.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:
getChannelCachein interfaceIGuildChannelContainer<GuildChannel>- Returns:
SortedChannelCacheView- Throws:
DetachedEntityException- If this entity isdetached
-
getChannels
Populated list ofchannelsfor 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
- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getChannels
Populated list ofchannelsfor 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
- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getRoleById
Gets aRolefrom this guild that has the same id as the one provided.
If there is noRolewith an id that matches the provided one, then this returnsnull.- Parameters:
id- The id of theRole.- Returns:
- Possibly-null
Rolewith matching id. - Throws:
NumberFormatException- If the providedidcannot be parsed byLong.parseLong(String)DetachedEntityException- If this entity isdetached
-
getRoleById
Gets aRolefrom this guild that has the same id as the one provided.
If there is noRolewith an id that matches the provided one, then this returnsnull.- Parameters:
id- The id of theRole.- Returns:
- Possibly-null
Rolewith matching id. - Throws:
DetachedEntityException- If this entity isdetached
-
getRoles
Gets allRolesin 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. - Throws:
DetachedEntityException- If this entity isdetached
-
getRolesByName
Gets a list of allRolesin this Guild that have the same name as the one provided.
If there are noRoleswith 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.
- Throws:
DetachedEntityException- If this entity isdetached
-
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_TAGSto be enabled. SeeJDABuilder.enableCache(...).- Parameters:
userId- The user id of the bot- Returns:
- The bot role, or null if no role matches
- Throws:
DetachedEntityException- If this entity isdetached
-
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_TAGSto 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 snowflakeDetachedEntityException- If this entity isdetached
-
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_TAGSto be enabled. SeeJDABuilder.enableCache(...).- Parameters:
user- The bot user- Returns:
- The bot role, or null if no role matches
- Throws:
IllegalArgumentException- If null is providedDetachedEntityException- If this entity isdetached
-
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_TAGSto be enabled. SeeJDABuilder.enableCache(...).- Returns:
- The bot role, or null if no role matches
- Throws:
DetachedEntityException- If this entity isdetached
-
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_TAGSto be enabled. SeeJDABuilder.enableCache(...).- Returns:
- The boost role, or null if no role matches
- Throws:
DetachedEntityException- If this entity isdetached
-
getRoleCache
SortedSnowflakeCacheViewof all cachedRolesof this Guild.
Roles are sorted according to their position.- Returns:
SortedSnowflakeCacheView- Throws:
DetachedEntityException- If this entity isdetached
-
getEmojiById
Gets aRichCustomEmojifrom this guild that has the same id as the one provided.
If there is noRichCustomEmojiwith an id that matches the provided one, then this returnsnull.Unicode emojis are not included as
RichCustomEmoji!This requires the
CacheFlag.EMOJIto be enabled!- Parameters:
id- the emoji id- Returns:
- An Emoji matching the specified id
- Throws:
NumberFormatException- If the providedidcannot be parsed byLong.parseLong(String)DetachedEntityException- If this entity isdetached- See Also:
-
getEmojiById
Gets anRichCustomEmojifrom this guild that has the same id as the one provided.
If there is noRichCustomEmojiwith an id that matches the provided one, then this returnsnull.Unicode emojis are not included as
RichCustomEmoji!This requires the
CacheFlag.EMOJIto be enabled!- Parameters:
id- the emoji id- Returns:
- An emoji matching the specified id
- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getEmojis
Gets allCustom Emojisbelonging 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.EMOJIto be enabled!- Returns:
- An immutable List of
Custom Emojis. - Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getEmojisByName
@Nonnull default @Unmodifiable List<RichCustomEmoji> getEmojisByName(@Nonnull String name, boolean ignoreCase) Gets a list of allCustom Emojisin this Guild that have the same name as the one provided.
If there are noEmojiswith the provided name, then this returns an empty list.Unicode emojis are not included as
RichCustomEmoji!This requires the
CacheFlag.EMOJIto 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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getEmojiCache
SnowflakeCacheViewof all cachedCustom Emojisof this Guild.
This will be empty ifCacheFlag.EMOJIis disabled.This requires the
CacheFlag.EMOJIto be enabled!- Returns:
SnowflakeCacheView- See Also:
-
getStickerById
Gets aGuildStickerfrom this guild that has the same id as the one provided.
If there is noGuildStickerwith an id that matches the provided one, then this returnsnull.This requires the
CacheFlag.STICKERto be enabled!- Parameters:
id- the sticker id- Returns:
- A Sticker matching the specified id
- Throws:
NumberFormatException- If the providedidcannot be parsed byLong.parseLong(String)DetachedEntityException- If this entity isdetached- See Also:
-
getStickerById
Gets aGuildStickerfrom this guild that has the same id as the one provided.
If there is noGuildStickerwith an id that matches the provided one, then this returnsnull.This requires the
CacheFlag.STICKERto be enabled!- Parameters:
id- the sticker id- Returns:
- A Sticker matching the specified id
- See Also:
-
getStickers
Gets all customGuildStickersbelonging 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.STICKERto be enabled!- Returns:
- An immutable List of
GuildStickers. - Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getStickersByName
@Nonnull default @Unmodifiable List<GuildSticker> getStickersByName(@Nonnull String name, boolean ignoreCase) Gets a list of allGuildStickersin this Guild that have the same name as the one provided.
If there are noGuildStickerswith the provided name, then this returns an empty list.This requires the
CacheFlag.STICKERto 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.
- Throws:
DetachedEntityException- If this entity isdetached
-
getStickerCache
SnowflakeCacheViewof all cachedGuildStickersof this Guild.
This will be empty ifCacheFlag.STICKERis disabled.This requires the
CacheFlag.STICKERto be enabled!- Returns:
SnowflakeCacheView- Throws:
DetachedEntityException- If this entity isdetached- 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- Throws:
DetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude 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 snowflakeDetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude 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:
DetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude 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- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveStickers
Retrieves all the stickers from this guild.
This also includesunavailablestickers.- Returns:
RestAction- Type: List ofGuildSticker- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveSticker
@Nonnull @CheckReturnValue RestAction<GuildSticker> retrieveSticker(@Nonnull StickerSnowflake sticker) Attempts to retrieve aGuildStickerobject for this guild based on the provided snowflake reference.The returned
RestActioncan 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 providedDetachedEntityException- If this entity isdetached
-
editSticker
Modify a sticker usingGuildStickerManager.
You can update multiple fields at once, by calling the respective setters before executing the request.The returned
RestActioncan 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_EXPRESSIONSin the guild.DetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancy
- Returns:
- The
BanPaginationActionof the guild's bans. - Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.BAN_MEMBERSpermission.DetachedEntityException- If this entity isdetached
-
retrieveBan
Retrieves aBanof the providedUserSnowflake.
If you wish to ban or unban a user, use eitherban(UserSnowflake, int, TimeUnit)orunban(UserSnowflake).Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflakefor 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_MEMBERSpermission.DetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude 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_MEMBERPermission.IllegalArgumentException- If the provided days are less than1or more than30DetachedEntityException- If this entity isdetached
-
getPublicRole
The @everyoneRoleof thisGuild.
This role is special because itspositionis 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 - Throws:
DetachedEntityException- If this entity isdetached
-
getDefaultChannel
The defaultStandardGuildChannelfor 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_CHANNELin.- Returns:
- The
channelrepresenting the default channel for this guild - Throws:
DetachedEntityException- If this entity isdetached
-
getManager
Returns theGuildManagerfor 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_SERVERDetachedEntityException- If this entity isdetached
-
isBoostProgressBarEnabled
boolean isBoostProgressBarEnabled()Returns whether this Guild has its boost progress bar shown.- Returns:
- True, if this Guild has its boost progress bar shown
- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveAuditLogs
APaginationActionimplementation that allows toiterateover allAuditLogEntriesof 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_LOGSDetachedEntityException- If this entity isdetached
-
leave
Used to leave a Guild.- Returns:
RestAction- Type:Void- Throws:
IllegalStateException- Thrown if the currently logged in account is the Owner of this Guild.DetachedEntityException- If this entity isdetached
-
getAudioManager
TheAudioManagerthat 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_STATESis disabledDetachedEntityException- If this entity isdetached- 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_OTHERSthis 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:
Taskrepresenting the request to speak. CallingTask.get()can result in deadlocks and should be avoided at all times.- Throws:
DetachedEntityException- If this entity isdetached- 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:
Taskrepresenting the request to speak cancellation. CallingTask.get()can result in deadlocks and should be avoided at all times.- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
getJDA
Returns theJDAinstance of this Guild- Returns:
- the corresponding JDA instance
-
retrieveInvites
Retrieves allInvitesfor this guild.
RequiresMANAGE_SERVERin this guild. Will throw anInsufficientPermissionExceptionotherwise.To get all invites for a
GuildChanneluseGuildChannel.retrieveInvites()- Returns:
RestAction- Type: List<Invite>
The list of expanded Invite objects- Throws:
InsufficientPermissionException- if the account does not haveMANAGE_SERVERin this Guild.DetachedEntityException- If this entity isdetached- See Also:
-
retrieveTemplates
Retrieves allTemplatesfor this guild.
RequiresMANAGE_SERVERin this guild. Will throw anInsufficientPermissionExceptionotherwise.- Returns:
RestAction- Type: List<Template>
The list of Template objects- Throws:
InsufficientPermissionException- if the account does not haveMANAGE_SERVERin this Guild.DetachedEntityException- If this entity isdetached
-
createTemplate
@Nonnull @CheckReturnValue RestAction<Template> createTemplate(@Nonnull String name, @Nullable String description) Used to create a newTemplatefor this Guild.
RequiresMANAGE_SERVERin this Guild. Will throw anInsufficientPermissionExceptionotherwise.Possible
ErrorResponsesinclude: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_SERVERin this GuildIllegalArgumentException- If the provided name isnullor not between 1-100 characters long, or if the provided description is not between 0-120 characters longDetachedEntityException- If this entity isdetached
-
retrieveWebhooks
Retrieves allWebhooksfor this Guild.
RequiresMANAGE_WEBHOOKSin 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_WEBHOOKSin this Guild.DetachedEntityException- If this entity isdetached- See Also:
-
retrieveWelcomeScreen
Retrieves thewelcome screenfor this Guild.
The welcome screen is shown to all members after joining the Guild.Possible
ErrorResponsesinclude: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_SERVERpermission
- Returns:
RestAction- Type:GuildWelcomeScreen
The welcome screen for this Guild.- Throws:
DetachedEntityException- If this entity isdetached
-
getVoiceStates
A list containing the cachedGuildVoiceStateof everyMemberconnected to an audio channel in this guild.This requires
CacheFlag.VOICE_STATEto be enabled.- Returns:
- Immutable list containing all cached
GuildVoiceStatesfor this guild.
-
retrieveMemberVoiceStateById
Load the member's voice state for the specified user.Possible
ErrorResponseExceptionsinclude:ErrorResponse.UNKNOWN_VOICE_STATE
The specified user does not exist, is not a member of this guild or is not connected to a voice channel
- Parameters:
id- The user id to load the voice state from- Returns:
RestAction- Type:GuildVoiceState- Throws:
DetachedEntityException- If this entity isdetached
-
retrieveMemberVoiceStateById
@Nonnull @CheckReturnValue default RestAction<GuildVoiceState> retrieveMemberVoiceStateById(@Nonnull String id) Load the member's voice state for the specified user.Possible
ErrorResponseExceptionsinclude:ErrorResponse.UNKNOWN_VOICE_STATE
The specified user does not exist, is not a member of this guild or is not connected to a voice channel
- Parameters:
id- The user id to load the voice state from- Returns:
RestAction- Type:GuildVoiceState- Throws:
IllegalArgumentException- If the provided id is empty or nullNumberFormatException- If the provided id is not a snowflakeDetachedEntityException- If this entity isdetached
-
retrieveMemberVoiceState
@Nonnull @CheckReturnValue default RestAction<GuildVoiceState> retrieveMemberVoiceState(@Nonnull UserSnowflake user) Load the member's voice state for the specifiedUserSnowflake.Possible
ErrorResponseExceptionsinclude:ErrorResponse.UNKNOWN_VOICE_STATE
The specified user does not exist, is not a member of this guild or is not connected to a voice channel
- Parameters:
user- TheUserSnowflakefor the member's voice state to retrieve. This can be a member or user instance orUser.fromId(long).- Returns:
RestAction- Type:GuildVoiceState- Throws:
IllegalArgumentException- If provided with nullDetachedEntityException- If this entity isdetached
-
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.- 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:
ExplicitContentLevelfor this Guild
-
loadMembers
Retrieves and collects members of this guild into a list.
This will use the configuredMemberCachePolicyto 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:ListofMember- Throws:
IllegalStateException- If theGatewayIntent.GUILD_MEMBERSis not enabledDetachedEntityException- If this entity isdetached
-
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 configuredMemberCachePolicyto 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:ListofMember- Throws:
IllegalArgumentException- If the provided filter is nullIllegalStateException- If theGatewayIntent.GUILD_MEMBERSis not enabledDetachedEntityException- If this entity isdetached
-
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 configuredMemberCachePolicyto 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:ListofMember- Throws:
IllegalArgumentException- If null is providedIllegalStateException- If theGatewayIntent.GUILD_MEMBERSis not enabledDetachedEntityException- If this entity isdetached- Since:
- 4.2.1
-
findMembersWithRoles
Retrieves and collects members of this guild into a list.
This will use the configuredMemberCachePolicyto 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:ListofMember- Throws:
IllegalArgumentException- If null is providedIllegalStateException- If theGatewayIntent.GUILD_MEMBERSis not enabledDetachedEntityException- If this entity isdetached- Since:
- 4.2.1
-
loadMembers
Retrieves all members of this guild.
This will use the configuredMemberCachePolicyto 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:
Taskcancellable handle for this request- Throws:
IllegalArgumentException- If the callback is nullIllegalStateException- If theGatewayIntent.GUILD_MEMBERSis not enabledDetachedEntityException- If this entity isdetached
-
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 enabledGatewayIntentsasGatewayIntent.GUILD_MEMBERSis 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
ErrorResponseExceptionsinclude:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Parameters:
user- TheUserSnowflakefor the member to retrieve. This can be a member or user instance orUser.fromId(long).- Returns:
RestAction- Type:Member- Throws:
IllegalArgumentException- If provided with nullDetachedEntityException- If this entity isdetached- 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 enabledGatewayIntentsasGatewayIntent.GUILD_MEMBERSis 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
ErrorResponseExceptionsinclude: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- Throws:
DetachedEntityException- If this entity isdetached- 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 enabledGatewayIntentsasGatewayIntent.GUILD_MEMBERSis 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
ErrorResponseExceptionsinclude: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 snowflakeDetachedEntityException- If this entity isdetached- 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 enabledGatewayIntentsasGatewayIntent.GUILD_MEMBERSis 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
ErrorResponseExceptionsinclude: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:
DetachedEntityException- If this entity isdetached- 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_PRESENCESintent is enabled, this will load theOnlineStatusandActivitiesof the members. You can useretrieveMembers(boolean, Collection)to disable presences.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If the input contains null
- If the input is more than 100 IDs
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent is enabled, this will load theOnlineStatusandActivitiesof the members. You can useretrieveMembersByIds(boolean, Collection)to disable presences.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If the input contains null
- If the input is more than 100 IDs
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent is enabled, this will load theOnlineStatusandActivitiesof the members. You can useretrieveMembersByIds(boolean, String...)to disable presences.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If the input contains null
- If the input is more than 100 IDs
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent is enabled, this will load theOnlineStatusandActivitiesof the members. You can useretrieveMembersByIds(boolean, long...)to disable presences.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If the input contains null
- If the input is more than 100 IDs
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent enabled.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If includePresence is
trueand the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 users
- If includePresence is
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent enabled.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If includePresence is
trueand the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent enabled.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If includePresence is
trueand the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
DetachedEntityException- If this entity isdetached
-
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_PRESENCESintent enabled.The requests automatically timeout after
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle for the request- Throws:
IllegalArgumentException-- If includePresence is
trueand the GUILD_PRESENCES intent is disabled - If the input contains null
- If the input is more than 100 IDs
- If includePresence is
DetachedEntityException- If this entity isdetached
-
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
10seconds. When the timeout occurs aTimeoutExceptionwill 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:
Taskhandle 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]
DetachedEntityException- If this entity isdetached- See Also:
-
retrieveActiveThreads
Retrieves the active threads in this guild.- Returns:
RestAction- List ofThreadChannel
-
retrieveScheduledEventById
@Nonnull @CheckReturnValue default CacheRestAction<ScheduledEvent> retrieveScheduledEventById(long id) Retrieves aScheduledEventby its ID.Possible
ErrorResponsesinclude: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- Throws:
DetachedEntityException- If this entity isdetached- See Also:
-
retrieveScheduledEventById
@Nonnull @CheckReturnValue CacheRestAction<ScheduledEvent> retrieveScheduledEventById(@Nonnull String id) Retrieves aScheduledEventby its ID.Possible
ErrorResponsesinclude: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 isnullor emptyNumberFormatException- If the specified ID cannot be parsed byLong.parseLong(String)DetachedEntityException- If this entity isdetached- See Also:
-
moveVoiceMember
@Nonnull @CheckReturnValue RestAction<Void> moveVoiceMember(@Nonnull UserSnowflake user, @Nullable AudioChannel audioChannel) Used to move a Member from oneAudioChannelto 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
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be moved due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNELpermission 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:
user- The member that you are moving.audioChannel- The destinationAudioChannelto which the member is being moved to. Or null to perform a voice kick.- Returns:
RestAction- Throws:
IllegalStateException- If the user is a Member and isn't currently in a AudioChannel in this Guild, orCacheFlag.VOICE_STATEis disabled.IllegalArgumentException-InsufficientPermissionException-- If this account doesn't have
Permission.VOICE_MOVE_OTHERSin the AudioChannel that the Member is currently in. - If this account AND the Member being moved don't have
Permission.VOICE_CONNECTfor the destination AudioChannel.
- If this account doesn't have
DetachedEntityException- If this entity isdetached
-
kickVoiceMember
Used to kick a member 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
ErrorResponsescaused by the returnedRestActioninclude 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:
user- The member that you are kicking.- Returns:
RestAction- Throws:
IllegalStateException- If the user is a Member and isn't currently in a AudioChannel in this Guild, orCacheFlag.VOICE_STATEis disabled.IllegalArgumentException-InsufficientPermissionException- If this account doesn't havePermission.VOICE_MOVE_OTHERSin the AudioChannel that the Member is currently in.DetachedEntityException- If this entity isdetached
-
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_CHANGEis required.
To change the nickname of anyMemberfor thisGuildthe PermissionNICKNAME_MANAGEis required.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheMemberfor which the nickname should be changed.nickname- The new nickname of theMember, max 32 characters in length, providenullor an empty String to reset the nickname- Returns:
AuditableRestAction- Throws:
IllegalArgumentException-InsufficientPermissionException-- If attempting to set nickname for self and the logged in account has neither
Permission.NICKNAME_CHANGEorPermission.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)DetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude 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_MEMBERPermission.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
DetachedEntityException- If this entity isdetached
-
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
ErrorResponsescaused by the returnedRestActioninclude 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_MEMBERPermission.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
DetachedEntityException- If this entity isdetached
-
modifySecurityIncidents
@Nonnull @CheckReturnValue AuditableRestAction<Void> modifySecurityIncidents(@Nonnull SecurityIncidentActions incidents) Update the current guildsecurity incident actions.
Security incident actions are used to temporarily disable features for the purpose of moderation.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:ErrorResponse.INVALID_FORM_BODY
If one of the provided timestamps is too far into the future
- Parameters:
incidents- The new security incidents- Returns:
AuditableRestAction- Throws:
IllegalArgumentException- If null is providedInsufficientPermissionException- If the account doesn't haveMANAGE_SERVERPermission.DetachedEntityException- If this entity isdetached- See Also:
-
kick
Kicks aMemberfrom theGuild.Note:
getMembers()will still contain theUseruntil Discord sends theGuildMemberRemoveEvent.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflakefor the user to kick. This can be a member or user instance orUser.fromId(long).- Returns:
AuditableRestActionKicks the provided Member from the current Guild- Throws:
IllegalArgumentException- If the user cannot be kicked from this Guild or the provideduseris null.InsufficientPermissionException- If the logged in account does not have thePermission.KICK_MEMBERSpermission.HierarchyException- If the logged in account cannot kick the other member due to permission hierarchy position. (SeeMember.canInteract(Member))DetachedEntityException- If this entity isdetached
-
ban
@Nonnull @CheckReturnValue AuditableRestAction<Void> ban(@Nonnull UserSnowflake user, int deletionTimeframe, @Nonnull TimeUnit unit) Bans the user specified by the providedUserSnowflakeand deletes messages sent by the user based on thedeletionTimeframe.
If you wish to ban a user without deleting any messages, providedeletionTimeframewith 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'sMemberobject (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
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_USER
The user does not exist
- Parameters:
user- TheUserSnowflakefor 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_MEMBERSpermission.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
DetachedEntityException- If this entity isdetached- 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
BulkBanResponseincludes 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
ErrorResponsescaused by the returnedRestActioninclude 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_MEMBERSorPermission.MANAGE_SERVERIllegalArgumentException-- If the users collection is null or contains null
- If the deletionTime is negative
DetachedEntityException- If this entity isdetached
-
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
BulkBanResponseincludes 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
ErrorResponsescaused by the returnedRestActioninclude 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_MEMBERSorPermission.MANAGE_SERVERIllegalArgumentException-- If null is provided
- If the deletionTimeframe is negative
DetachedEntityException- If this entity isdetached
-
unban
Unbans the specifiedUserSnowflakefrom this Guild.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The target Member cannot be unbanned due to a permission discrepancyUNKNOWN_BAN
The specified User is not banned from the current GuildUNKNOWN_USER
The specified User does not exist
- Parameters:
user- TheUserSnowflaketo 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_MEMBERSpermission.IllegalArgumentException- If the provided user is nullDetachedEntityException- If this entity isdetached
-
timeoutFor
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutFor(@Nonnull UserSnowflake user, long amount, @Nonnull TimeUnit unit) Puts the specified Member in time out in thisGuildfor a specific amount of time.
While a Member is in time out, they cannot send messages, reply, react, or speak in voice channels.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflaketo timeout. This can be a member or user instance orUser.fromId(long).amount- The amount of the providedunitto put the specified Member in time out forunit- TheUnittype ofamount- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.MODERATE_MEMBERSpermission.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
useris null - The provided
amountis lower than or equal to0 - The provided
unitis null - The provided
amountwith theunitresults in a date that is more than 28 days in the future
- The provided
DetachedEntityException- If this entity isdetached
-
timeoutFor
@Nonnull @CheckReturnValue default AuditableRestAction<Void> timeoutFor(@Nonnull UserSnowflake user, @Nonnull Duration duration) Puts the specified Member in time out in thisGuildfor a specific amount of time.
While a Member is in time out, all permissions exceptVIEW_CHANNELandMESSAGE_HISTORYare removed from them.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflaketo 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_MEMBERSpermission.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
useris null - The provided
durationis null - The provided
durationresults in a date that is more than 28 days in the future
- The provided
DetachedEntityException- If this entity isdetached
-
timeoutUntil
@Nonnull @CheckReturnValue AuditableRestAction<Void> timeoutUntil(@Nonnull UserSnowflake user, @Nonnull TemporalAccessor temporal) Puts the specified Member in time out in thisGuilduntil the specified date.
While a Member is in time out, all permissions exceptVIEW_CHANNELandMESSAGE_HISTORYare removed from them.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflaketo 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_MEMBERSpermission.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
useris null - The provided
temporalis null - The provided
temporalis in the past - The provided
temporalis more than 28 days in the future
- The provided
DetachedEntityException- If this entity isdetached
-
removeTimeout
Removes a time out from the specified Member in thisGuild.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflaketo 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_MEMBERSpermission.HierarchyException- If the logged in account cannot remove the timeout from the other Member due to permission hierarchy position. (SeeMember.canInteract(Member))DetachedEntityException- If this entity isdetached
-
deafen
@Nonnull @CheckReturnValue AuditableRestAction<Void> deafen(@Nonnull UserSnowflake user, boolean deafen) Sets the Guild Deafened state of theMemberbased on the provided boolean.Note: The Member's
GuildVoiceState.isGuildDeafened()value won't change until JDA receives theGuildVoiceGuildDeafenEventevent related to this change.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflakewho'sGuildVoiceStateto change. This can be a member or user instance orUser.fromId(long).deafen- Whether thisMembershould be deafened or undeafened.- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.VOICE_DEAF_OTHERSpermission in the given channel.IllegalArgumentException- If the provided user is null.IllegalStateException- If the provided user is not currently connected to a voice channel.DetachedEntityException- If this entity isdetached
-
mute
@Nonnull @CheckReturnValue AuditableRestAction<Void> mute(@Nonnull UserSnowflake user, boolean mute) Sets the Guild Muted state of theMemberbased on the provided boolean.Note: The Member's
GuildVoiceState.isGuildMuted()value won't change until JDA receives theGuildVoiceGuildMuteEventevent related to this change.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflakewho'sGuildVoiceStateto change. This can be a member or user instance orUser.fromId(long).mute- Whether thisMembershould be muted or unmuted.- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the logged in account does not have thePermission.VOICE_DEAF_OTHERSpermission in the given channel.IllegalArgumentException- If the provided user is null.IllegalStateException- If the provided user is not currently connected to a voice channel.DetachedEntityException- If this entity isdetached
-
addRoleToMember
@Nonnull @CheckReturnValue AuditableRestAction<Void> addRoleToMember(@Nonnull UserSnowflake user, @Nonnull Role role) Atomically assigns the providedRoleto 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
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflaketo 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_ROLESHierarchyException- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountDetachedEntityException- If this entity isdetached
-
removeRoleFromMember
@Nonnull @CheckReturnValue AuditableRestAction<Void> removeRoleFromMember(@Nonnull UserSnowflake user, @Nonnull Role role) Atomically removes the providedRolefrom 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
ErrorResponsescaused by the returnedRestActioninclude 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- TheUserSnowflaketo 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_ROLESHierarchyException- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountDetachedEntityException- If this entity isdetached
-
modifyMemberRoles
@Nonnull @CheckReturnValue AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nullable Collection<Role> rolesToAdd, @Nullable Collection<Role> rolesToRemove) Modifies theRolesof the specifiedMemberby 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 inrolesToAddandrolesToRemoveit 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 aGenericGuildMemberEventtargeting 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
ErrorResponsescaused by the returnedRestActioninclude 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- TheMemberthat should be modifiedrolesToAdd- ACollectionofRolesto add to the current Roles the specifiedMemberalready has, or nullrolesToRemove- ACollectionofRolesto remove from the current Roles the specifiedMemberalready has, or null- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_ROLESHierarchyException- 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 Roleof the Guild
- If the target member is
DetachedEntityException- If this entity isdetached
-
modifyMemberRoles
@Nonnull @CheckReturnValue default AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nonnull Role... roles) Modifies the completeRoleset 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 aGenericGuildMemberEventtargeting the same Member.The new roles must not contain the Public Role of the Guild
Possible
ErrorResponsescaused by the returnedRestActioninclude 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- AMemberof which to override the Roles ofroles- New collection ofRolesfor the specified Member- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_ROLESHierarchyException- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountIllegalArgumentException-DetachedEntityException- If this entity isdetached- See Also:
-
modifyMemberRoles
@Nonnull @CheckReturnValue AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nonnull Collection<Role> roles) Modifies the completeRoleset 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 aGenericGuildMemberEventtargeting the same Member.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- AMemberof which to override the Roles ofroles- New collection ofRolesfor the specified Member- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_ROLESHierarchyException- If the provided roles are higher in the Guild's hierarchy and thus cannot be modified by the currently logged in accountIllegalArgumentException-DetachedEntityException- If this entity isdetached- See Also:
-
createTextChannel
@Nonnull @CheckReturnValue default ChannelAction<TextChannel> createTextChannel(@Nonnull String name) Creates a newTextChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermissionPossible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createTextChannel
@Nonnull @CheckReturnValue ChannelAction<TextChannel> createTextChannel(@Nonnull String name, @Nullable Category parent) Creates a newTextChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermissionPossible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 characters; or the provided parent is not in the same guild.DetachedEntityException- If this entity isdetached
-
createNewsChannel
@Nonnull @CheckReturnValue default ChannelAction<NewsChannel> createNewsChannel(@Nonnull String name) Creates a newNewsChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermissionPossible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createNewsChannel
@Nonnull @CheckReturnValue ChannelAction<NewsChannel> createNewsChannel(@Nonnull String name, @Nullable Category parent) Creates a newNewsChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermissionPossible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 characters; or the provided parent is not in the same guild.DetachedEntityException- If this entity isdetached
-
createVoiceChannel
@Nonnull @CheckReturnValue default ChannelAction<VoiceChannel> createVoiceChannel(@Nonnull String name) Creates a newVoiceChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createVoiceChannel
@Nonnull @CheckReturnValue ChannelAction<VoiceChannel> createVoiceChannel(@Nonnull String name, @Nullable Category parent) Creates a newVoiceChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 characters; or the provided parent is not in the same guild.DetachedEntityException- If this entity isdetached
-
createStageChannel
@Nonnull @CheckReturnValue default ChannelAction<StageChannel> createStageChannel(@Nonnull String name) Creates a newStageChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createStageChannel
@Nonnull @CheckReturnValue ChannelAction<StageChannel> createStageChannel(@Nonnull String name, @Nullable Category parent) Creates a newStageChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 characters; or the provided parent is not in the same guild.DetachedEntityException- If this entity isdetached
-
createForumChannel
@Nonnull @CheckReturnValue default ChannelAction<ForumChannel> createForumChannel(@Nonnull String name) Creates a newForumChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createForumChannel
@Nonnull @CheckReturnValue ChannelAction<ForumChannel> createForumChannel(@Nonnull String name, @Nullable Category parent) Creates a newForumChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 characters; or the provided parent is not in the same guild.DetachedEntityException- If this entity isdetached
-
createMediaChannel
@Nonnull @CheckReturnValue default ChannelAction<MediaChannel> createMediaChannel(@Nonnull String name) Creates a newMediaChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createMediaChannel
@Nonnull @CheckReturnValue ChannelAction<MediaChannel> createMediaChannel(@Nonnull String name, @Nullable Category parent) Creates a newMediaChannelin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 characters; or the provided parent is not in the same guild.DetachedEntityException- If this entity isdetached
-
createCategory
Creates a newCategoryin this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNELPermission.Possible
ErrorResponsescaused by the returnedRestActioninclude 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_CHANNELpermissionIllegalArgumentException- If the provided name isnull, blank, or longer than 100 charactersDetachedEntityException- If this entity isdetached
-
createCopyOfChannel
@Nonnull @CheckReturnValue default <T extends ICopyableChannel> ChannelAction<T> createCopyOfChannel(@Nonnull T channel) Creates a copy of the specifiedGuildChannelin 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
ErrorResponsescaused by the returnedRestActioninclude 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- TheGuildChannelto 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 isnullInsufficientPermissionException- If the currently logged in account does not have theMANAGE_CHANNELPermissionDetachedEntityException- If this entity isdetached- Since:
- 3.1
- See Also:
-
createRole
Creates a newRolein 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_ROLESPermissionPossible
ErrorResponsescaused by the returnedRestActioninclude 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_ROLESPermissionDetachedEntityException- If this entity isdetached
-
createCopyOfRole
Creates a newRolein thisGuildwith 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_ROLESPermission and allPermissionsthe givenRolehas.Possible
ErrorResponsescaused by the returnedRestActioninclude 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- TheRolethat 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_ROLESPermission and every Permission the provided Role hasIllegalArgumentException- If the specified role isnullDetachedEntityException- If this entity isdetached
-
createEmoji
@Nonnull @CheckReturnValue AuditableRestAction<RichCustomEmoji> createEmoji(@Nonnull String name, @Nonnull Icon icon, @Nonnull Role... roles) Creates a newRichCustomEmojiin 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_EXPRESSIONSPermission.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_EMOJIfeature (seeGuild.getFeatures()).
Due to simplicity we do not check for these limits.Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The emoji could not be created due to a permission discrepancy
- Parameters:
name- The name for the new emojiicon- TheIconfor the new emojiroles- TheRolesthe 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_EXPRESSIONSPermissionDetachedEntityException- If this entity isdetached
-
createSticker
@Nonnull @CheckReturnValue AuditableRestAction<GuildSticker> createSticker(@Nonnull String name, @Nonnull String description, @Nonnull FileUpload file, @Nonnull Collection<String> tags) Creates a newGuildStickerin this Guild.Possible
ErrorResponsesinclude: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_EXPRESSIONSpermissionIllegalArgumentException-- 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
DetachedEntityException- If this entity isdetached
-
createSticker
@Nonnull @CheckReturnValue default AuditableRestAction<GuildSticker> createSticker(@Nonnull String name, @Nonnull String description, @Nonnull FileUpload file, @Nonnull String tag, @Nonnull String... tags) Creates a newGuildStickerin this Guild.Possible
ErrorResponsesinclude: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_EXPRESSIONSpermissionIllegalArgumentException-- 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
DetachedEntityException- If this entity isdetached
-
deleteSticker
Deletes a sticker from the guild.The returned
RestActioncan 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_EXPRESSIONSin the guild.DetachedEntityException- If this entity isdetached
-
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_EVENTSis 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
nullor 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
DetachedEntityException- If this entity isdetached
-
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
nullor 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
DetachedEntityException- If this entity isdetached
-
-
modifyCategoryPositions
Modifies the positional order ofGuild.getCategories()using a specificRestActionextension to allow moving Channelsup/downortoa specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponsesinclude: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- Throws:
DetachedEntityException- If this entity isdetached
-
modifyTextChannelPositions
Modifies the positional order ofGuild.getTextChannels()using a specificRestActionextension to allow moving Channelsup/downortoa specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponsesinclude: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- Throws:
DetachedEntityException- If this entity isdetached
-
modifyVoiceChannelPositions
Modifies the positional order ofGuild.getVoiceChannels()using a specificRestActionextension to allow moving Channelsup/downortoa specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponsesinclude: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- Throws:
DetachedEntityException- If this entity isdetached
-
modifyTextChannelPositions
@Nonnull @CheckReturnValue CategoryOrderAction modifyTextChannelPositions(@Nonnull Category category) Modifies the positional order ofCategory#getTextChannels()using an extension ofChannelOrderActionspecialized for ordering the nestedTextChannelsof thisCategory.
LikeChannelOrderAction, the returnedCategoryOrderActioncan be used to move TextChannelsup,down, ortoa specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponsesinclude: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- TheCategoryto orderTextChannelsfrom.- Returns:
CategoryOrderAction- Type:TextChannel- Throws:
DetachedEntityException- If this entity isdetached
-
modifyVoiceChannelPositions
@Nonnull @CheckReturnValue CategoryOrderAction modifyVoiceChannelPositions(@Nonnull Category category) Modifies the positional order ofCategory#getVoiceChannels()using an extension ofChannelOrderActionspecialized for ordering the nestedVoiceChannelsof thisCategory.
LikeChannelOrderAction, the returnedCategoryOrderActioncan be used to move VoiceChannelsup,down, ortoa specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponsesinclude: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- TheCategoryto orderVoiceChannelsfrom.- Returns:
CategoryOrderAction- Type:VoiceChannels- Throws:
DetachedEntityException- If this entity isdetached
-
modifyRolePositions
Modifies the positional order ofGuild.getRoles()using a specificRestActionextension to allow moving Rolesup/downortoa 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 - 1and the highest role at index0.
ProvidingtruetomodifyRolePositions(boolean)will result in the ordering being in ascending order, with the highest role at indexn - 1and the lowest at index0.
As a note:Member.getRoles()andGuild.getRoles()are both in descending order, just like this method.Possible
ErrorResponsesinclude: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- Throws:
DetachedEntityException- If this entity isdetached
-
modifyRolePositions
Modifies the positional order ofGuild.getRoles()using a specificRestActionextension to allow moving Rolesup/downortoa specific position.Possible
ErrorResponsesinclude: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 index0and the lowest role at indexn - 1. Providingtruewill result in the ordering being in ascending order, with the lower role at index0and the highest at indexn - 1.
As a note:Member.getRoles()andGuild.getRoles()are both in descending order.- Returns:
RoleOrderAction- Throws:
DetachedEntityException- If this entity isdetached
-
modifyWelcomeScreen
TheManagerfor 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_SERVERDetachedEntityException- If this entity isdetached
-