Class GuildImpl
- All Implemented Interfaces:
IGuildChannelContainer<GuildChannel>
,IDetachableEntity
,Guild
,ISnowflake
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.entities.Guild
Guild.Ban, Guild.BoostTier, Guild.ExplicitContentLevel, Guild.MetaData, Guild.MFALevel, Guild.NotificationLevel, Guild.NSFWLevel, Guild.Timeout, Guild.VerificationLevel
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.Guild
BANNER_URL, ICON_URL, SPLASH_URL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMember
(String accessToken, UserSnowflake user) Adds the user to this guild as a member.addRoleToMember
(UserSnowflake user, Role role) ban
(Collection<? extends UserSnowflake> users, Duration deletionTime) Bans up to 200 of the provided users.ban
(UserSnowflake user, int duration, TimeUnit unit) Bans the user specified by the providedUserSnowflake
and deletes messages sent by the user based on thedeletionTimeframe
.Cancels theRequest-to-Speak
.Creates a newAutoModRule
for this guild.createCategory
(String name) Creates a newCategory
in this Guild.createEmoji
(String name, Icon icon, Role... roles) Creates a newRichCustomEmoji
in this Guild.createForumChannel
(String name, Category parent) Creates a newForumChannel
in this Guild.createMediaChannel
(String name, Category parent) Creates a newMediaChannel
in this Guild.createNewsChannel
(String name, Category parent) Creates a newNewsChannel
in this Guild.Creates a newRole
in this Guild.createScheduledEvent
(String name, String location, OffsetDateTime startTime, OffsetDateTime endTime) Creates a newScheduledEvent
.createScheduledEvent
(String name, GuildChannel channel, OffsetDateTime startTime) Creates a newScheduledEvent
.createStageChannel
(String name, Category parent) Creates a newStageChannel
in this Guild.createSticker
(String name, String description, FileUpload file, Collection<String> tags) Creates a newGuildSticker
in this Guild.createTemplate
(String name, String description) Used to create a newTemplate
for this Guild.createTextChannel
(String name, Category parent) Creates a newTextChannel
in this Guild.createVoiceChannel
(String name, Category parent) Creates a newVoiceChannel
in this Guild.deafen
(UserSnowflake user, boolean deafen) Sets the Guild Deafened state of theMember
based on the provided boolean.delete()
Used to completely delete a Guild.Used to completely delete a guild.Deletes theAutoModRule
for the provided id.deleteCommandById
(String commandId) Delete the command for this id.Deletes a sticker from the guild.editCommandById
(Command.Type type, String id) Edit an existing command by id.editSticker
(StickerSnowflake sticker) Modify a sticker usingGuildStickerManager
.boolean
Provides theVoiceChannel
that has been set as the channel whichMembers
will be moved to after they have been inactive in aVoiceChannel
for longer thanGuild.getAfkTimeout()
.TheTimeout
set for this Guild representing the amount of time that must pass for a Member to have had no activity in aVoiceChannel
to be considered AFK.TheAudioManager
that represents the audio connection for this Guild.The guild banner id.int
The amount of boosts this server currently has.Sorted list ofMembers
that boost this guild.The boost tier for this guild.SortedSnowflakeCacheView
ofCategory
.getChannels
(boolean includeHidden) Populated list ofchannels
for this guild.Provides theTextChannel
that receives community updates.getConnectedMembers
(GuildChannel channel) The defaultStandardGuildChannel
for aGuild
.Returns the default message Notification-Level of this Guild.The description for this guild.SnowflakeCacheView
of all cachedCustom Emojis
of this Guild.The level of content filtering enabled in this Guild.The Features of theGuild
.getGuildChannelById
(long id) GetGuildChannel
for the provided ID.getGuildChannelById
(ChannelType type, long id) GetGuildChannel
for the provided ID.The Discord hash-id of theGuild
icon image.long
The Snowflake id of this entity.getJDA()
Returns theJDA
instance of this GuildThe preferred locale for this guild.Returns theGuildManager
for this Guild, used to modify all properties and settings of the Guild.int
The maximum amount of members that can join this guild.int
The maximum amount of connected members this guild can have at a time.getMember
(UserSnowflake user) Gets the Guild specificMember
object for the providedUserSnowflake
.MemberCacheView
for all cachedMembers
of this Guild.int
The expected member count for this guild.getName()
The human readable name of theGuild
.SortedSnowflakeCacheView
ofNewsChannel
.Returns the NSFW Level that this guild is classified with.getOwner()
TheMember
object for the owner of this Guild.long
The ID for the current owner of this guild.Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.SortedSnowflakeCacheView
of all cachedRoles
of this Guild.Provides theTextChannel
that lists the rules of the guild.Provides theTextChannel
that receives discord safety alerts.SortedSnowflakeCacheView
of all cachedScheduledEvents
of this Guild.The current guildsecurity incident actions
.The current security incident detections.Gets theMember
object of the currently logged in account in this guild.The Discord hash-id of the splash image for this Guild.SortedSnowflakeCacheView
ofStageChannel
.SnowflakeCacheView
of all cachedGuildStickers
of this Guild.Provides theTextChannel
that has been set as the channel which newly joinedMembers
will be announced in.SortedSnowflakeCacheView
ofTextChannel
.The vanity url code for this Guild.Returns the verification-Level of this Guild.SortedSnowflakeCacheView
ofVoiceChannel
.getVoiceState
(Member member) A list containing the cachedGuildVoiceState
of everyMember
connected to an audio channel in this guild.void
handleVoiceStateUpdate
(GuildVoiceStateImpl voiceState) int
hashCode()
void
boolean
Returns whether this Guild has its boost progress bar shown.boolean
Whether this entity is detached.boolean
isLoaded()
Whether this guild has loaded members.boolean
isMember
(UserSnowflake user) Used to determine if the providedUserSnowflake
is a member of this Guild.kick
(UserSnowflake user) leave()
Used to leave a Guild.loadMembers
(Consumer<Member> callback) Retrieves all members of this guild.Returns anAutoModRuleManager
, which can be used to modify the rule for the provided id.Modifies the positional order ofGuild.getCategories()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.modifyMemberRoles
(Member member, Collection<Role> roles) modifyMemberRoles
(Member member, Collection<Role> rolesToAdd, Collection<Role> rolesToRemove) modifyNickname
(Member member, String nickname) Changes the Member's nickname in this guild.modifyRolePositions
(boolean useAscendingOrder) Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.modifySecurityIncidents
(SecurityIncidentActions incidents) Update the current guildsecurity incident actions
.Modifies the positional order ofGuild.getTextChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.modifyTextChannelPositions
(Category category) Modifies the positional order ofCategory#getTextChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedTextChannels
of thisCategory
.Modifies the positional order ofGuild.getVoiceChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.modifyVoiceChannelPositions
(Category category) Modifies the positional order ofCategory#getVoiceChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedVoiceChannels
of thisCategory
.TheManager
for this guild's welcome screen, used to modify properties of the welcome screen like if the welcome screen is enabled, the description and welcome channels.moveVoiceMember
(UserSnowflake user, AudioChannel audioChannel) Used to move a Member from oneAudioChannel
to anotherAudioChannel
.mute
(UserSnowflake user, boolean mute) Sets the Guild Muted state of theMember
based on the provided boolean.void
void
onMemberRemove
(long memberId) This method will prune (kick) all members who were offline for at least days days.void
Re-apply theMemberCachePolicy
of this session to allMembers
of this Guild.removeRoleFromMember
(UserSnowflake user, Role role) removeTimeout
(UserSnowflake user) Removes a time out from the specified Member in thisGuild
.Once the currently logged in account is connected to aStageChannel
, this will trigger aRequest-to-Speak
(aka raise your hand).Retrieves the active threads in this guild.Retrieves theAutoModRule
for the provided id.Retrieves all currentAutoModRules
for this guild.retrieveBan
(UserSnowflake user) Retrieves aBan
of the providedUserSnowflake
.Retrieves an immutable list of the currently bannedUsers
.Retrieves the existingCommand
instance by id.Retrieves theIntegrationPrivileges
for the commands in this guild.retrieveCommands
(boolean withLocalizations) Retrieves the list of guild commands.Retrieves a custom emoji together with its respective creator.Retrieves an immutable list of Custom Emojis together with their respective creators.retrieveIntegrationPrivilegesById
(String targetId) Retrieves theIntegrationPrivileges
for the target with the specified ID.Retrieves allInvites
for this guild.retrieveMemberById
(long id) Load the member for the specified user.retrieveMembersByIds
(boolean includePresence, long... ids) 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.retrieveMemberVoiceStateById
(long id) Load the member's voice state for the specified user.LoadsGuild.MetaData
for this guild instance.retrievePrunableMemberCount
(int days) The method calculates the amount of Members that would be pruned ifGuild.prune(int, Role...)
was executed.retrieveRegions
(boolean includeDeprecated) Retrieves the available regions for this GuildretrieveScheduledEventById
(long id) Retrieves aScheduledEvent
by its ID.Retrieves aScheduledEvent
by its ID.retrieveScheduledEvents
(boolean includeUserCount) Retrieves allScheduledEvents
for this guild.retrieveSticker
(StickerSnowflake sticker) Attempts to retrieve aGuildSticker
object for this guild based on the provided snowflake reference.Retrieves all the stickers from this guild.Retrieves allTemplates
for this guild.Retrieves the Vanity Invite meta data for this guild.Retrieves allWebhooks
for this Guild.Retrieves thewelcome screen
for this Guild.setAfkChannel
(VoiceChannel afkChannel) setAfkTimeout
(Guild.Timeout afkTimeout) setBannerId
(String bannerId) setBoostCount
(int count) setBoostProgressBarEnabled
(boolean enabled) setBoostTier
(int tier) setCommunityUpdatesChannel
(TextChannel communityUpdatesChannel) setDescription
(String description) setFeatures
(Set<String> features) setLocale
(DiscordLocale locale) setMaxMembers
(int maxMembers) setMaxPresences
(int maxPresences) setMemberCount
(int count) setNSFWLevel
(Guild.NSFWLevel nsfwLevel) setOwnerId
(long ownerId) setPublicRole
(Role publicRole) setRulesChannel
(TextChannel rulesChannel) setSafetyAlertsChannel
(TextChannel safetyAlertsChannel) setSplashId
(String splashId) setSystemChannel
(TextChannel systemChannel) setVanityCode
(String code) boolean
shouldCacheVoiceState
(long userId) timeoutUntil
(UserSnowflake user, TemporalAccessor temporal) Puts the specified Member in time out in thisGuild
until the specified date.toString()
transferOwnership
(Member newOwner) Transfers the Guild ownership to the specifiedMember
Only available if the currently logged in account is the owner of this Guildunban
(UserSnowflake user) Unbans the specifiedUserSnowflake
from this Guild.void
uncacheChannel
(GuildChannel channel, boolean keepThreads) boolean
unloadMember
(long userId) Attempts to remove the user with the provided id from the member cache.void
Configures the complete list of guild commands.void
upsertCommand
(CommandData command) Creates or updates a command.Methods inherited from interface net.dv8tion.jda.api.entities.Guild
ban, createCopyOfChannel, createCopyOfRole, createForumChannel, createMediaChannel, createNewsChannel, createStageChannel, createSticker, createTextChannel, createVoiceChannel, deleteAutoModRuleById, deleteCommandById, editCommandById, findMembers, findMembersWithRoles, findMembersWithRoles, getBanner, getBannerUrl, getBoostRole, getBotRole, getChannels, getEmojiById, getEmojiById, getEmojis, getEmojisByName, getIcon, getIconUrl, getMaxBitrate, getMaxEmojis, getMaxFileSize, getMemberById, getMemberById, getMemberByTag, getMemberByTag, getMembers, getMembersByEffectiveName, getMembersByName, getMembersByNickname, getMembersWithRoles, getMembersWithRoles, getOwnerId, getRoleByBot, getRoleByBot, getRoleByBot, getRoleById, getRoleById, getRoles, getRolesByName, getScheduledEventById, getScheduledEventById, getScheduledEvents, getScheduledEventsByName, getSplash, getSplashUrl, getStickerById, getStickerById, getStickers, getStickersByName, getVanityUrl, isInvitesDisabled, kickVoiceMember, loadMembers, modifyAutoModRuleById, modifyMemberRoles, modifyRolePositions, prune, retrieveAutoModRuleById, retrieveCommandById, retrieveCommands, retrieveEmoji, retrieveEmojiById, retrieveIntegrationPrivilegesById, retrieveMember, retrieveMemberById, retrieveMembers, retrieveMembers, retrieveMembersByIds, retrieveMembersByIds, retrieveMembersByIds, retrieveMembersByIds, retrieveMembersByIds, retrieveMemberVoiceState, retrieveMemberVoiceStateById, retrieveOwner, retrieveRegions, retrieveScheduledEvents, timeoutFor, timeoutFor, upsertCommand
Methods inherited from interface net.dv8tion.jda.api.entities.channel.attribute.IGuildChannelContainer
getCategories, getCategoriesByName, getCategoryById, getCategoryById, getChannelById, getChannelById, getForumChannelById, getForumChannelById, getForumChannels, getForumChannelsByName, getGuildChannelById, getGuildChannelById, getMediaChannelById, getMediaChannelById, getMediaChannels, getMediaChannelsByName, getNewsChannelById, getNewsChannelById, getNewsChannels, getNewsChannelsByName, getStageChannelById, getStageChannelById, getStageChannels, getStageChannelsByName, getTextChannelById, getTextChannelById, getTextChannels, getTextChannelsByName, getThreadChannelById, getThreadChannelById, getThreadChannels, getThreadChannelsByName, getVoiceChannelById, getVoiceChannelById, getVoiceChannels, getVoiceChannelsByName
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
Constructor Details
-
GuildImpl
-
-
Method Details
-
isDetached
public boolean isDetached()Description copied from interface:IDetachableEntity
Whether this entity is detached.If this returns
true
, this entity cannot be retrieved, will never be updated, and most methods that would otherwise return aRestAction
will throw aDetachedEntityException
instead.- Specified by:
isDetached
in interfaceIDetachableEntity
- Returns:
True
, if the entity is detached
-
invalidate
public void invalidate() -
uncacheChannel
-
retrieveCommands
Description copied from interface:Guild
Retrieves the list of guild commands.
This list does not include global commands! UseJDA.retrieveCommands()
for global commands.- Specified by:
retrieveCommands
in interfaceGuild
- Parameters:
withLocalizations
-true
if the localization data (such as name and description) should be included- Returns:
RestAction
- Type:List
ofCommand
-
retrieveCommandById
Description copied from interface:Guild
Retrieves the existingCommand
instance by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Specified by:
retrieveCommandById
in interfaceGuild
- Parameters:
id
- The command id- Returns:
RestAction
- Type:Command
-
upsertCommand
Description copied from interface:Guild
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
Guild.updateCommands()
instead.You need the OAuth2 scope
"applications.commands"
in order to add commands to a guild.- Specified by:
upsertCommand
in interfaceGuild
- Parameters:
command
- TheCommandData
for the command- Returns:
RestAction
- Type:Command
The RestAction used to create or update the command- See Also:
-
updateCommands
Description copied from interface:Guild
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();
- Specified by:
updateCommands
in interfaceGuild
- Returns:
CommandListUpdateAction
- See Also:
-
editCommandById
Description copied from interface:Guild
Edit an existing command by id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Specified by:
editCommandById
in interfaceGuild
- Parameters:
type
- The command typeid
- The id of the command to edit- Returns:
CommandEditAction
used to edit the command
-
deleteCommandById
Description copied from interface:Guild
Delete the command for this id.If there is no command with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Specified by:
deleteCommandById
in interfaceGuild
- Parameters:
commandId
- The id of the command that should be deleted- Returns:
RestAction
-
retrieveIntegrationPrivilegesById
@Nonnull public RestAction<List<IntegrationPrivilege>> retrieveIntegrationPrivilegesById(@Nonnull String targetId) Description copied from interface:Guild
Retrieves theIntegrationPrivileges
for the target with the specified ID.
The ID can either be of a Command or Application!Moderators of a guild can modify these privileges through the Integrations Menu
If there is no command or application with the provided ID, this RestAction fails with
ErrorResponse.UNKNOWN_COMMAND
- Specified by:
retrieveIntegrationPrivilegesById
in interfaceGuild
- Parameters:
targetId
- The id of the command (global or guild), or application- Returns:
RestAction
- Type:List
ofIntegrationPrivilege
-
retrieveCommandPrivileges
Description copied from interface:Guild
Retrieves theIntegrationPrivileges
for the commands in this guild.
The RestAction provides aPrivilegeConfig
providing the privileges of this application and its commands.Moderators of a guild can modify these privileges through the Integrations Menu
- Specified by:
retrieveCommandPrivileges
in interfaceGuild
- Returns:
RestAction
- Type:PrivilegeConfig
-
retrieveRegions
Description copied from interface:Guild
Retrieves the available regions for this Guild- Specified by:
retrieveRegions
in interfaceGuild
- Parameters:
includeDeprecated
- Whether to include deprecated regions- Returns:
RestAction
- TypeEnumSet
-
retrieveAutoModRules
Description copied from interface:Guild
Retrieves all currentAutoModRules
for this guild.- Specified by:
retrieveAutoModRules
in interfaceGuild
- Returns:
RestAction
- Type:List
ofAutoModRule
-
retrieveAutoModRuleById
Description copied from interface:Guild
Retrieves theAutoModRule
for the provided id.- Specified by:
retrieveAutoModRuleById
in interfaceGuild
- Parameters:
id
- The id of the rule- Returns:
RestAction
- Type:AutoModRule
-
createAutoModRule
Description copied from interface:Guild
Creates a newAutoModRule
for this guild.You can only create a certain number of rules for each
AutoModTriggerType
. The maximum is provided byAutoModTriggerType.getMaxPerGuild()
.- Specified by:
createAutoModRule
in interfaceGuild
- Parameters:
rule
- The data for the new rule- Returns:
AuditableRestAction
- Type:AutoModRule
-
modifyAutoModRuleById
Description copied from interface:Guild
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()
.- Specified by:
modifyAutoModRuleById
in interfaceGuild
- Returns:
- The manager instance
-
deleteAutoModRuleById
Description copied from interface:Guild
Deletes theAutoModRule
for the provided id.- Specified by:
deleteAutoModRuleById
in interfaceGuild
- Parameters:
id
- The id of the rule- Returns:
AuditableRestAction
- Type:Void
-
addMember
Description copied from interface:Guild
Adds the user to this guild as a member.
This requires an OAuth2 Access Token with the scopeguilds.join
.- Specified by:
addMember
in interfaceGuild
- Parameters:
accessToken
- The access tokenuser
- TheUserSnowflake
for the member to add. This can be a member or user instance orUser.fromId(long)
.- Returns:
MemberAction
- See Also:
-
isLoaded
public boolean isLoaded()Description copied from interface:Guild
Whether this guild has loaded members.
This will always be false if theGUILD_MEMBERS
intent is disabled. -
pruneMemberCache
public void pruneMemberCache()Description copied from interface:Guild
Re-apply theMemberCachePolicy
of this session to allMembers
of this Guild.Example
// Check if the members of this guild have at least 50% bots (bot collection/farm) public void checkBots(Guild guild) { // Keep in mind: This requires the GUILD_MEMBERS intent which is disabled in createDefault and createLight by default guild.retrieveMembers() // Load members CompletableFuture<Void> (async and eager) .thenApply((v) -> guild.getMemberCache()) // Turn into CompletableFuture<MemberCacheView> .thenAccept((members) -> { int total = members.size(); // Casting to double to get a double as result of division, don't need to worry about precision with small counts like this double bots = (double) members.applyStream(stream -> stream.map(Member::getUser) .filter(User::isBot) .count()); // Count bots if (bots / total > 0.5) // Check how many members are bots System.out.println("More than 50% of members in this guild are bots"); }) .thenRun(guild::pruneMemberCache); // Then prune the cache }
- Specified by:
pruneMemberCache
in interfaceGuild
- See Also:
-
unloadMember
public boolean unloadMember(long userId) Description copied from interface:Guild
Attempts to remove the user with the provided id from the member cache.
If you attempt to remove theSelfUser
this will simply returnfalse
.This should be used by an implementation of
MemberCachePolicy
as an upstream request to remove a member. For example a Least-Recently-Used (LRU) cache might use this to drop old members if the cache capacity is reached. Or a timeout cache could use this to remove expired members.- Specified by:
unloadMember
in interfaceGuild
- Parameters:
userId
- The target user id- Returns:
- True, if the cache was changed
- See Also:
-
getMemberCount
public int getMemberCount()Description copied from interface:Guild
The expected member count for this guild.
If this guild is not lazy loaded this should be identical to the size returned byGuild.getMemberCache()
.When
GatewayIntent.GUILD_MEMBERS
is disabled, this will not be updated.- Specified by:
getMemberCount
in interfaceGuild
- Returns:
- The expected member count for this guild
-
getName
Description copied from interface:Guild
The human readable name of theGuild
.This value can be modified using
GuildManager.setName(String)
. -
getIconId
Description copied from interface:Guild
The Discord hash-id of theGuild
icon image. If no icon has been set, this returnsnull
.The Guild icon can be modified using
GuildManager.setIcon(Icon)
. -
getFeatures
Description copied from interface:Guild
The Features of theGuild
.Features can be updated using
GuildManager.setFeatures(Collection)
.- Specified by:
getFeatures
in interfaceGuild
- Returns:
- Never-null, unmodifiable Set containing all of the Guild's features.
- See Also:
-
getSplashId
Description copied from interface:Guild
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)
.- Specified by:
getSplashId
in interfaceGuild
- Returns:
- Possibly-null String containing the Guild's splash hash-id
-
getVanityCode
Description copied from interface:Guild
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.- Specified by:
getVanityCode
in interfaceGuild
- Returns:
- The vanity code or null
- See Also:
-
retrieveVanityInvite
Description copied from interface:Guild
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 useGuild.getVanityUrl()
if you only care about the invite.This action requires the
MANAGE_SERVER
permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:INVITE_CODE_INVALID
If this guild does not have a vanity inviteMISSING_PERMISSIONS
The vanity invite cannot be fetched due to a permission discrepancy
- Specified by:
retrieveVanityInvite
in interfaceGuild
- Returns:
RestAction
- Type:VanityInvite
-
getDescription
Description copied from interface:Guild
The description for this guild.
This is displayed in the server browser below the guild name for verified guilds.The description can be modified using
GuildManager.setDescription(String)
.- Specified by:
getDescription
in interfaceGuild
- Returns:
- The description
-
getLocale
Description copied from interface:Guild
The preferred locale for this guild.
If the guild doesn't have the COMMUNITY feature, this returns the default.
Default:DiscordLocale.ENGLISH_US
- Specified by:
getLocale
in interfaceGuild
- Returns:
- The preferred
DiscordLocale
for this guild
-
getBannerId
Description copied from interface:Guild
The guild banner id.
This is shown in guilds below the guild name.The banner can be modified using
GuildManager.setBanner(Icon)
.- Specified by:
getBannerId
in interfaceGuild
- Returns:
- The guild banner id or null
- See Also:
-
getBoostTier
Description copied from interface:Guild
The boost tier for this guild.
Each tier unlocks new perks for a guild that can be seen in thefeatures
.- Specified by:
getBoostTier
in interfaceGuild
- Returns:
- The boost tier.
-
getBoostCount
public int getBoostCount()Description copied from interface:Guild
The amount of boosts this server currently has.- Specified by:
getBoostCount
in interfaceGuild
- Returns:
- The boost count
-
getBoosters
Description copied from interface:Guild
Sorted list ofMembers
that boost this guild.
The list is sorted byMember.getTimeBoosted()
ascending. This means the first element will be the member who has been boosting for the longest time.This will only check cached members!
SeeMemberCachePolicy
- Specified by:
getBoosters
in interfaceGuild
- Returns:
- Immutable list of members who boost this guild
-
getMaxMembers
public int getMaxMembers()Description copied from interface:Guild
The maximum amount of members that can join this guild.- Specified by:
getMaxMembers
in interfaceGuild
- Returns:
- The maximum amount of members
- See Also:
-
getMaxPresences
public int getMaxPresences()Description copied from interface:Guild
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.- Specified by:
getMaxPresences
in interfaceGuild
- Returns:
- The maximum amount of connected members this guild can have
- See Also:
-
retrieveMetaData
Description copied from interface:Guild
LoadsGuild.MetaData
for this guild instance.- Specified by:
retrieveMetaData
in interfaceGuild
- Returns:
RestAction
- Type:Guild.MetaData
-
getAfkChannel
Description copied from interface:Guild
Provides theVoiceChannel
that has been set as the channel whichMembers
will be moved to after they have been inactive in aVoiceChannel
for longer thanGuild.getAfkTimeout()
.
If no channel has been set as the AFK channel, this returnsnull
.This value can be modified using
GuildManager.setAfkChannel(VoiceChannel)
.- Specified by:
getAfkChannel
in interfaceGuild
- Returns:
- Possibly-null
VoiceChannel
that is the AFK Channel.
-
getSystemChannel
Description copied from interface:Guild
Provides theTextChannel
that has been set as the channel which newly joinedMembers
will be announced in.
If no channel has been set as the system channel, this returnsnull
.This value can be modified using
GuildManager.setSystemChannel(TextChannel)
.- Specified by:
getSystemChannel
in interfaceGuild
- Returns:
- Possibly-null
TextChannel
that is the system Channel.
-
getRulesChannel
Description copied from interface:Guild
Provides theTextChannel
that lists the rules of the guild.
If this guild doesn't have the COMMUNITYfeature
, this returnsnull
.- Specified by:
getRulesChannel
in interfaceGuild
- Returns:
- Possibly-null
TextChannel
that is the rules channel - See Also:
-
retrieveScheduledEvents
Description copied from interface:Guild
Retrieves allScheduledEvents
for this guild.- Specified by:
retrieveScheduledEvents
in interfaceGuild
- Parameters:
includeUserCount
- Whether to include user counts for theScheduledEvents
.- Returns:
RestAction
- Type:List
ofScheduledEvent
-
retrieveScheduledEventById
Description copied from interface:Guild
Retrieves aScheduledEvent
by its ID.Possible
ErrorResponses
include:ErrorResponse.UNKNOWN_SCHEDULED_EVENT
A scheduled event with the specified ID does not exist in this guild, or the currently logged in user does not have access to it.
- Specified by:
retrieveScheduledEventById
in interfaceGuild
- Parameters:
id
- The ID of theScheduledEvent
- Returns:
RestAction
- Type:ScheduledEvent
- See Also:
-
retrieveScheduledEventById
Description copied from interface:Guild
Retrieves aScheduledEvent
by its ID.Possible
ErrorResponses
include:ErrorResponse.UNKNOWN_SCHEDULED_EVENT
A scheduled event with the specified ID does not exist in the guild, or the currently logged in user does not have access to it.
- Specified by:
retrieveScheduledEventById
in interfaceGuild
- Parameters:
id
- The ID of theScheduledEvent
- Returns:
RestAction
- Type:ScheduledEvent
- See Also:
-
createScheduledEvent
@Nonnull public ScheduledEventAction createScheduledEvent(@Nonnull String name, @Nonnull String location, @Nonnull OffsetDateTime startTime, @Nonnull OffsetDateTime endTime) Description copied from interface:Guild
Creates a newScheduledEvent
. Events created with this method will be ofType.EXTERNAL
. These events are set to take place at an external location.Requirements
Events are required to have a name, location and start time. Additionally, an end time must also be specified for events ofType.EXTERNAL
.Permission.MANAGE_EVENTS
is required on the guild level in order to create this type of event.Example
guild.createScheduledEvent("Cactus Beauty Contest", "Mike's Backyard", OffsetDateTime.now().plusHours(1), OffsetDateTime.now().plusHours(3)) .setDescription("Come and have your cacti judged! _Must be spikey to enter_") .queue();
- Specified by:
createScheduledEvent
in interfaceGuild
- 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
-
createScheduledEvent
@Nonnull public ScheduledEventAction createScheduledEvent(@Nonnull String name, @Nonnull GuildChannel channel, @Nonnull OffsetDateTime startTime) Description copied from interface:Guild
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();
- Specified by:
createScheduledEvent
in interfaceGuild
- 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
-
-
getCommunityUpdatesChannel
Description copied from interface:Guild
Provides theTextChannel
that receives community updates.
If this guild doesn't have the COMMUNITYfeature
, this returnsnull
.- Specified by:
getCommunityUpdatesChannel
in interfaceGuild
- Returns:
- Possibly-null
TextChannel
that is the community updates channel - See Also:
-
getSafetyAlertsChannel
Description copied from interface:Guild
Provides theTextChannel
that receives discord safety alerts.
If this guild doesn't have the COMMUNITYfeature
, this returnsnull
.- Specified by:
getSafetyAlertsChannel
in interfaceGuild
- Returns:
- Possibly-null
TextChannel
that is the saferty alerts channel. - See Also:
-
retrieveWebhooks
Description copied from interface:Guild
Retrieves allWebhooks
for this Guild.
RequiresMANAGE_WEBHOOKS
in this Guild.To get all webhooks for a specific
TextChannel
, useIWebhookContainer.retrieveWebhooks()
- Specified by:
retrieveWebhooks
in interfaceGuild
- Returns:
RestAction
- Type: List<Webhook
>
A list of all Webhooks in this Guild.- See Also:
-
getOwner
Description copied from interface:Guild
TheMember
object for the owner of this Guild.
This is null when the owner is no longer in this guild or not yet loaded (lazy loading). Sometimes owners of guilds delete their account or get banned by Discord.If lazy-loading is used it is recommended to use
Guild.retrieveOwner()
instead.Ownership can be transferred using
Guild.transferOwnership(Member)
.This only works when the member was added to cache. Lazy loading might load this later.
SeeMemberCachePolicy
-
getOwnerIdLong
public long getOwnerIdLong()Description copied from interface:Guild
The ID for the current owner of this guild.
This is useful for debugging purposes or as a shortcut.- Specified by:
getOwnerIdLong
in interfaceGuild
- Returns:
- The ID for the current owner
- See Also:
-
getAfkTimeout
Description copied from interface:Guild
TheTimeout
set for this Guild representing the amount of time that must pass for a Member to have had no activity in aVoiceChannel
to be considered AFK. IfGuild.getAfkChannel()
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)
.- Specified by:
getAfkTimeout
in interfaceGuild
- Returns:
- The
Timeout
set for this Guild.
-
getSecurityIncidentActions
Description copied from interface:Guild
The current guildsecurity incident actions
.
Security incident actions are used to temporarily disable features for the purpose of moderation.- Specified by:
getSecurityIncidentActions
in interfaceGuild
- Returns:
SecurityIncidentActions
the current actions
-
getSecurityIncidentDetections
Description copied from interface:Guild
The current security incident detections.
Discord may automatically detect spammers or raiders.- Specified by:
getSecurityIncidentDetections
in interfaceGuild
- Returns:
SecurityIncidentDetections
the current detections
-
isMember
Description copied from interface:Guild
Used to determine if the providedUserSnowflake
is a member of this Guild.This will only check cached members! If the cache is not loaded (see
Guild.isLoaded()
), this may return false despite the user being a member. This is false whenGuild.getMember(UserSnowflake)
returnsnull
. -
getSelfMember
Description copied from interface:Guild
Gets theMember
object of the currently logged in account in this guild.
This is basicallyJDA.getSelfUser()
being provided toGuild.getMember(UserSnowflake)
.- Specified by:
getSelfMember
in interfaceGuild
- Returns:
- The Member object of the currently logged in account.
-
getMember
Description copied from interface:Guild
Gets the Guild specificMember
object for the providedUserSnowflake
.
If the user is not in this guild or currently uncached,null
is returned.This will only check cached members!
- Specified by:
getMember
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
for the member to get. This can be a member or user instance orUser.fromId(long)
.- Returns:
- Possibly-null
Member
for the relatedUser
. - See Also:
-
getMemberCache
Description copied from interface:Guild
MemberCacheView
for all cachedMembers
of this Guild.This will only provide cached members!
SeeMemberCachePolicy
- Specified by:
getMemberCache
in interfaceGuild
- Returns:
MemberCacheView
- See Also:
-
getScheduledEventCache
Description copied from interface:Guild
SortedSnowflakeCacheView
of all cachedScheduledEvents
of this Guild.
Scheduled events are sorted by their start time, and events that start at the same time are sorted by their snowflake ID.This requires
CacheFlag.SCHEDULED_EVENTS
to be enabled.- Specified by:
getScheduledEventCache
in interfaceGuild
- Returns:
SortedSnowflakeCacheView
-
getCategoryCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofCategory
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getCategoryCache
in interfaceGuild
- Specified by:
getCategoryCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getTextChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofTextChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getTextChannelCache
in interfaceGuild
- Specified by:
getTextChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getNewsChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofNewsChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getNewsChannelCache
in interfaceGuild
- Specified by:
getNewsChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getVoiceChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofVoiceChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getVoiceChannelCache
in interfaceGuild
- Specified by:
getVoiceChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getForumChannelCache
Description copied from interface:IGuildChannelContainer
SnowflakeCacheView
ofForumChannel
.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getForumChannelCache
in interfaceGuild
- Specified by:
getForumChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SnowflakeCacheView
-
getMediaChannelCache
Description copied from interface:IGuildChannelContainer
SnowflakeCacheView
ofMediaChannel
.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getMediaChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SnowflakeCacheView
-
getStageChannelCache
Description copied from interface:IGuildChannelContainer
SortedSnowflakeCacheView
ofStageChannel
.
InGuild
cache, channels are sorted according to their position and id.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getStageChannelCache
in interfaceGuild
- Specified by:
getStageChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedSnowflakeCacheView
-
getThreadChannelCache
Description copied from interface:IGuildChannelContainer
SnowflakeCacheView
ofThreadChannel
.These threads can also represent posts in
ForumChannels
.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.- Specified by:
getThreadChannelCache
in interfaceGuild
- Specified by:
getThreadChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SnowflakeCacheView
-
getChannelCache
Description copied from interface:Guild
SortedChannelCacheView
ofGuildChannel
.Provides cache access to all channels of this guild, including thread channels (unlike
Guild.getChannels()
). The cache view attempts to provide a sorted list, based on how channels are displayed in the client. Various methods likeCacheView.forEachUnordered(Consumer)
orCacheView.lockedIterator()
bypass sorting for optimization reasons.It is possible to filter the channels to more specific types using
ChannelCacheView.getElementById(ChannelType, long)
orSortedChannelCacheView.ofType(Class)
.- Specified by:
getChannelCache
in interfaceGuild
- Specified by:
getChannelCache
in interfaceIGuildChannelContainer<GuildChannel>
- Returns:
SortedChannelCacheView
-
getGuildChannelById
Description copied from interface:IGuildChannelContainer
GetGuildChannel
for the provided ID.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.To get more specific channel types you can use one of the following:
IGuildChannelContainer.getChannelById(Class, long)
IGuildChannelContainer.getTextChannelById(long)
IGuildChannelContainer.getNewsChannelById(long)
IGuildChannelContainer.getStageChannelById(long)
IGuildChannelContainer.getVoiceChannelById(long)
IGuildChannelContainer.getCategoryById(long)
IGuildChannelContainer.getForumChannelById(long)
- Specified by:
getGuildChannelById
in interfaceIGuildChannelContainer<GuildChannel>
- Parameters:
id
- The ID of the channel- Returns:
- The GuildChannel or null
-
getGuildChannelById
Description copied from interface:IGuildChannelContainer
GetGuildChannel
for the provided ID.This getter exists on any instance of
IGuildChannelContainer
and only checks the caches with the relevant scoping. ForGuild
,JDA
, orShardManager
, this returns the relevant channel with respect to the cache within each of those objects. For a guild, this would mean it only returns channels within the same guild.
If this is called onJDA
orShardManager
, this may return null immediately after building, because the cache isn't initialized yet. To make sure the cache is initialized after building yourJDA
instance, you can useJDA.awaitReady()
.
This is meant for systems that use a dynamicChannelType
and can profit from a simple function to get the channel instance.To get more specific channel types you can use one of the following:
IGuildChannelContainer.getChannelById(Class, long)
IGuildChannelContainer.getTextChannelById(long)
IGuildChannelContainer.getNewsChannelById(long)
IGuildChannelContainer.getStageChannelById(long)
IGuildChannelContainer.getVoiceChannelById(long)
IGuildChannelContainer.getCategoryById(long)
IGuildChannelContainer.getForumChannelById(long)
- Specified by:
getGuildChannelById
in interfaceIGuildChannelContainer<GuildChannel>
- Parameters:
type
- TheChannelType
id
- The ID of the channel- Returns:
- The GuildChannel or null
-
getRoleCache
Description copied from interface:Guild
SortedSnowflakeCacheView
of all cachedRoles
of this Guild.
Roles are sorted according to their position.- Specified by:
getRoleCache
in interfaceGuild
- Returns:
SortedSnowflakeCacheView
-
getEmojiCache
Description copied from interface:Guild
SnowflakeCacheView
of all cachedCustom Emojis
of this Guild.
This will be empty ifCacheFlag.EMOJI
is disabled.This requires the
CacheFlag.EMOJI
to be enabled!- Specified by:
getEmojiCache
in interfaceGuild
- Returns:
SnowflakeCacheView
- See Also:
-
getStickerCache
Description copied from interface:Guild
SnowflakeCacheView
of all cachedGuildStickers
of this Guild.
This will be empty ifCacheFlag.STICKER
is disabled.This requires the
CacheFlag.STICKER
to be enabled!- Specified by:
getStickerCache
in interfaceGuild
- Returns:
SnowflakeCacheView
- See Also:
-
getChannels
Description copied from interface:Guild
Populated list ofchannels
for this guild.
This includes all types of channels, except for threads.The returned list is ordered in the same fashion as it would be by the official discord client.
- TextChannel, ForumChannel, and NewsChannel without parent
- VoiceChannel and StageChannel without parent
- Categories
- TextChannel, ForumChannel, and NewsChannel with category as parent
- VoiceChannel and StageChannel with category as parent
- Specified by:
getChannels
in interfaceGuild
- Parameters:
includeHidden
- Whether to include channels with deniedView Channel Permission
- Returns:
- Immutable list of channels for this guild
- See Also:
-
retrieveEmojis
Description copied from interface:Guild
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
.- Specified by:
retrieveEmojis
in interfaceGuild
- Returns:
RestAction
- Type: List ofRichCustomEmoji
-
retrieveEmojiById
Description copied from interface:Guild
Retrieves a custom emoji together with its respective creator.
This does not include unicode emoji.Note that
RichCustomEmoji.getOwner()
is only available if the currently logged in account hasPermission.MANAGE_GUILD_EXPRESSIONS
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:UNKNOWN_EMOJI
If the provided id does not correspond to an emoji in this guild
- Specified by:
retrieveEmojiById
in interfaceGuild
- Parameters:
id
- The emoji id- Returns:
RestAction
- Type:RichCustomEmoji
-
retrieveStickers
Description copied from interface:Guild
Retrieves all the stickers from this guild.
This also includesunavailable
stickers.- Specified by:
retrieveStickers
in interfaceGuild
- Returns:
RestAction
- Type: List ofGuildSticker
-
retrieveSticker
Description copied from interface:Guild
Attempts to retrieve aGuildSticker
object for this guild based on the provided snowflake reference.The returned
RestAction
can encounter the following Discord errors:UNKNOWN_STICKER
Occurs when the provided id does not refer to a sticker known by Discord.
- Specified by:
retrieveSticker
in interfaceGuild
- 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.
-
editSticker
Description copied from interface:Guild
Modify a sticker usingGuildStickerManager
.
You can update multiple fields at once, by calling the respective setters before executing the request.The returned
RestAction
can encounter the following Discord errors:UNKNOWN_STICKER
Occurs when the provided id does not refer to a sticker known by Discord.
- Specified by:
editSticker
in interfaceGuild
- Returns:
GuildStickerManager
-
retrieveBanList
Description copied from interface:Guild
Retrieves an immutable list of the currently bannedUsers
.
If you wish to ban or unban a user, use eitherGuild.ban(UserSnowflake, int, TimeUnit)
orGuild.unban(UserSnowflake)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancy
- Specified by:
retrieveBanList
in interfaceGuild
- Returns:
- The
BanPaginationAction
of the guild's bans.
-
retrieveBan
Description copied from interface:Guild
Retrieves aBan
of the providedUserSnowflake
.
If you wish to ban or unban a user, use eitherGuild.ban(UserSnowflake, int, TimeUnit)
orGuild.unban(UserSnowflake)
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The ban list cannot be fetched due to a permission discrepancyUNKNOWN_BAN
Either the ban was removed before finishing the task or it did not exist in the first place
- Specified by:
retrieveBan
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
for the banned user. This can be a user instance orUser.fromId(long)
.- Returns:
RestAction
- Type:Ban
An unmodifiable ban object for the user banned from this guild
-
retrievePrunableMemberCount
Description copied from interface:Guild
The method calculates the amount of Members that would be pruned ifGuild.prune(int, Role...)
was executed. Prunability is determined by a Member being offline for at least days days.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The prune count cannot be fetched due to a permission discrepancy
- Specified by:
retrievePrunableMemberCount
in interfaceGuild
- 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.
-
getPublicRole
Description copied from interface:Guild
The @everyoneRole
of thisGuild
.
This role is special because itsposition
is calculated as-1
. All other role positions are 0 or greater. This implies that the public role is always below any custom roles created in this Guild. Additionally, all members of this guild are implied to have this role so it is not included in the list returned byMember.getRoles()
.
The ID of this Role is the Guild's ID thus it is equivalent to usinggetRoleById(getIdLong())
.- Specified by:
getPublicRole
in interfaceGuild
- Returns:
- The @everyone
Role
-
getDefaultChannel
Description copied from interface:Guild
The defaultStandardGuildChannel
for aGuild
.
This is the channel that the Discord client will default to opening when a Guild is opened for the first time when accepting an invite that is not directed at a specificchannel
.Note: This channel is the first channel in the guild (ordered by position) that the
Guild.getPublicRole()
has thePermission.VIEW_CHANNEL
in.- Specified by:
getDefaultChannel
in interfaceGuild
- Returns:
- The
channel
representing the default channel for this guild
-
getManager
Description copied from interface:Guild
Returns theGuildManager
for this Guild, used to modify all properties and settings of the Guild.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Specified by:
getManager
in interfaceGuild
- Returns:
- The Manager of this Guild
-
isBoostProgressBarEnabled
public boolean isBoostProgressBarEnabled()Description copied from interface:Guild
Returns whether this Guild has its boost progress bar shown.- Specified by:
isBoostProgressBarEnabled
in interfaceGuild
- Returns:
- True, if this Guild has its boost progress bar shown
-
retrieveAuditLogs
Description copied from interface:Guild
APaginationAction
implementation that allows toiterate
over allAuditLogEntries
of this Guild.
This iterates from the most recent action to the first logged one. (Limit 90 days into history by discord api)Examples
public void logBan(GuildBanEvent event) { Guild guild = event.getGuild(); List<TextChannel> modLog = guild.getTextChannelsByName("mod-log", true); guild.retrieveAuditLogs() .type(ActionType.BAN) // filter by type .limit(1) .queue(list -> { if (list.isEmpty()) return; AuditLogEntry entry = list.get(0); String message = String.format("%#s banned %#s with reason %s", entry.getUser(), event.getUser(), entry.getReason()); modLog.forEach(channel -> channel.sendMessage(message).queue() ); }); }
- Specified by:
retrieveAuditLogs
in interfaceGuild
- Returns:
AuditLogPaginationAction
-
leave
Description copied from interface:Guild
Used to leave a Guild. If the currently logged in account is the owner of this guild (Guild.getOwner()
) then ownership of the Guild needs to be transferred to a differentMember
before leaving usingGuild.transferOwnership(Member)
.- Specified by:
leave
in interfaceGuild
- Returns:
RestAction
- Type:Void
-
delete
Description copied from interface:Guild
Used to completely delete a Guild. This can only be done if the currently logged in account is the owner of the Guild.
If the account has MFA enabled, useGuild.delete(String)
instead to provide the MFA code.- Specified by:
delete
in interfaceGuild
- Returns:
RestAction
- Type:Void
-
delete
Description copied from interface:Guild
Used to completely delete a guild. This can only be done if the currently logged in account is the owner of the Guild.
This method is specifically used for when MFA is enabled on the logged in accountSelfUser.isMfaEnabled()
. If MFA is not enabled, useGuild.delete()
.- Specified by:
delete
in interfaceGuild
- Parameters:
mfaCode
- The Multifactor Authentication code generated by an app like Google Authenticator.
This is not the MFA token given to you by Discord. The code is typically 6 characters long.- Returns:
RestAction
- Type:Void
-
getAudioManager
Description copied from interface:Guild
TheAudioManager
that represents the audio connection for this Guild.
If no AudioManager exists for this Guild, this will create a new one.
This operation is synchronized on all audio managers for this JDA instance, this means that calling getAudioManager() on any other guild while a thread is accessing this method may be locked.- Specified by:
getAudioManager
in interfaceGuild
- Returns:
- The AudioManager for this Guild.
- See Also:
-
requestToSpeak
Description copied from interface:Guild
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 useGuild.cancelRequestToSpeak()
to move back to the audience or cancel your pending request.If the self member has
Permission.VOICE_MUTE_OTHERS
this will immediately promote them to speaker.Example:
stageChannel.createStageInstance("Talent Show").queue() guild.requestToSpeak(); // Set request to speak flag guild.getAudioManager().openAudioConnection(stageChannel); // join the channel
- Specified by:
requestToSpeak
in interfaceGuild
- Returns:
Task
representing the request to speak. CallingTask.get()
can result in deadlocks and should be avoided at all times.- See Also:
-
cancelRequestToSpeak
Description copied from interface:Guild
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.- Specified by:
cancelRequestToSpeak
in interfaceGuild
- Returns:
Task
representing the request to speak cancellation. CallingTask.get()
can result in deadlocks and should be avoided at all times.- See Also:
-
getJDA
Description copied from interface:Guild
Returns theJDA
instance of this Guild -
getVoiceStates
Description copied from interface:Guild
A list containing the cachedGuildVoiceState
of everyMember
connected to an audio channel in this guild.This requires
CacheFlag.VOICE_STATE
to be enabled.- Specified by:
getVoiceStates
in interfaceGuild
- Returns:
- Immutable list containing all cached
GuildVoiceStates
for this guild.
-
retrieveMemberVoiceStateById
@Nonnull @CheckReturnValue public CacheRestAction<GuildVoiceState> retrieveMemberVoiceStateById(long id) Description copied from interface:Guild
Load the member's voice state for the specified user.Possible
ErrorResponseExceptions
include: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
- Specified by:
retrieveMemberVoiceStateById
in interfaceGuild
- Parameters:
id
- The user id to load the voice state from- Returns:
RestAction
- Type:GuildVoiceState
-
getVerificationLevel
Description copied from interface:Guild
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)
.- Specified by:
getVerificationLevel
in interfaceGuild
- Returns:
- The Verification-Level of this Guild.
-
getDefaultNotificationLevel
Description copied from interface:Guild
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)
.- Specified by:
getDefaultNotificationLevel
in interfaceGuild
- Returns:
- The default message Notification-Level of this Guild.
-
getRequiredMFALevel
Description copied from interface:Guild
Returns the level of multifactor authentication required to execute administrator restricted functions in this guild.
For a short description of the different values, seeMFALevel
.This value can be modified using
GuildManager.setRequiredMFALevel(net.dv8tion.jda.api.entities.Guild.MFALevel)
.- Specified by:
getRequiredMFALevel
in interfaceGuild
- Returns:
- The MFA-Level required by this Guild.
-
getExplicitContentLevel
Description copied from interface:Guild
The level of content filtering enabled in this Guild.
This decides which messages sent by which Members will be scanned for explicit content.- Specified by:
getExplicitContentLevel
in interfaceGuild
- Returns:
ExplicitContentLevel
for this Guild
-
loadMembers
Description copied from interface:Guild
Retrieves all members of this guild.
This will use the configuredMemberCachePolicy
to decide which members to retain in cache.This requires the privileged GatewayIntent.GUILD_MEMBERS to be enabled!
You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Specified by:
loadMembers
in interfaceGuild
- Parameters:
callback
- Consumer callback for each member- Returns:
Task
cancellable handle for this request
-
retrieveMemberById
Description copied from interface:Guild
Load the member for the specified user.
If the member is already loaded it will be retrieved fromGuild.getMemberById(long)
and immediately provided if the member information is consistent. The cache consistency directly relies on the enabledGatewayIntents
asGatewayIntent.GUILD_MEMBERS
is required to keep the cache updated with the latest information. You can useuseCache(false)
to always make a new request, which is the default behavior if the required intents are disabled.Possible
ErrorResponseExceptions
include:ErrorResponse.UNKNOWN_MEMBER
The specified user is not a member of this guildErrorResponse.UNKNOWN_USER
The specified user does not exist
- Specified by:
retrieveMemberById
in interfaceGuild
- Parameters:
id
- The user id to load the member from- Returns:
RestAction
- Type:Member
- See Also:
-
retrieveMembersByIds
@Nonnull public Task<List<Member>> retrieveMembersByIds(boolean includePresence, @Nonnull long... ids) Description copied from interface:Guild
Retrieves a list of members by their user id.
If the id does not resolve to a member of this guild, then it will not appear in the resulting list. It is possible that none of the IDs resolve to a member, in which case an empty list will be the result.You can only load presences with the
GUILD_PRESENCES
intent enabled.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Specified by:
retrieveMembersByIds
in interfaceGuild
- Parameters:
includePresence
- Whether to load presences of the members (online status/activity)ids
- The ids of the members (max 100)- Returns:
Task
handle for the request
-
retrieveMembersByPrefix
@Nonnull @CheckReturnValue public Task<List<Member>> retrieveMembersByPrefix(@Nonnull String prefix, int limit) Description copied from interface:Guild
Queries a list of members using a radix tree based on the provided name prefix.
This will check both the username and the nickname of the members. Additional filtering may be required. If no members with the specified prefix exist, the list will be empty.The requests automatically timeout after
10
seconds. When the timeout occurs aTimeoutException
will be used to complete exceptionally.You MUST NOT use blocking operations such as
Task.get()
! The response handling happens on the event thread by default.- Specified by:
retrieveMembersByPrefix
in interfaceGuild
- Parameters:
prefix
- The case-insensitive name prefixlimit
- The max amount of members to retrieve (1-100)- Returns:
Task
handle for the request- See Also:
-
retrieveActiveThreads
Description copied from interface:Guild
Retrieves the active threads in this guild.- Specified by:
retrieveActiveThreads
in interfaceGuild
- Returns:
RestAction
- List ofThreadChannel
-
getIdLong
public long getIdLong()Description copied from interface:ISnowflake
The Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLong
in interfaceISnowflake
- Returns:
- Long containing the Id.
-
retrieveInvites
Description copied from interface:Guild
Retrieves allInvites
for this guild.
RequiresMANAGE_SERVER
in this guild. Will throw anInsufficientPermissionException
otherwise.To get all invites for a
GuildChannel
useGuildChannel.retrieveInvites()
- Specified by:
retrieveInvites
in interfaceGuild
- Returns:
RestAction
- Type: List<Invite
>
The list of expanded Invite objects- See Also:
-
retrieveTemplates
Description copied from interface:Guild
Retrieves allTemplates
for this guild.
RequiresMANAGE_SERVER
in this guild. Will throw anInsufficientPermissionException
otherwise.- Specified by:
retrieveTemplates
in interfaceGuild
- Returns:
RestAction
- Type: List<Template
>
The list of Template objects
-
createTemplate
@Nonnull public RestAction<Template> createTemplate(@Nonnull String name, @Nullable String description) Description copied from interface:Guild
Used to create a newTemplate
for this Guild.
RequiresMANAGE_SERVER
in this Guild. Will throw anInsufficientPermissionException
otherwise.Possible
ErrorResponses
include:Guild already has a template
The guild already has a template.
- Specified by:
createTemplate
in interfaceGuild
- Parameters:
name
- The name of the templatedescription
- The description of the template- Returns:
RestAction
- Type:Template
The created Template object
-
retrieveWelcomeScreen
Description copied from interface:Guild
Retrieves thewelcome screen
for this Guild.
The welcome screen is shown to all members after joining the Guild.Possible
ErrorResponses
include:Unknown Guild Welcome Screen
The guild has no welcome screenMissing Permissions
The guild's welcome screen is disabled and the currently logged in account doesn't have theMANAGE_SERVER
permission
- Specified by:
retrieveWelcomeScreen
in interfaceGuild
- Returns:
RestAction
- Type:GuildWelcomeScreen
The welcome screen for this Guild.
-
moveVoiceMember
@Nonnull public RestAction<Void> moveVoiceMember(@Nonnull UserSnowflake user, @Nullable AudioChannel audioChannel) Description copied from interface:Guild
Used to move a Member from oneAudioChannel
to anotherAudioChannel
.
As a note, you cannot move a Member that isn't already in a AudioChannel. Also they must be in a AudioChannel in the same Guild as the one that you are moving them to.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be moved due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission was removedUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUNKNOWN_CHANNEL
The specified channel was deleted before finishing the task
- Specified by:
moveVoiceMember
in interfaceGuild
- Parameters:
user
- The member that you are moving.audioChannel
- The destinationAudioChannel
to which the member is being moved to. Or null to perform a voice kick.- Returns:
RestAction
-
modifyNickname
Description copied from interface:Guild
Changes the Member's nickname in this guild. The nickname is visible to all members of this guild.To change the nickname for the currently logged in account only the Permission
NICKNAME_CHANGE
is required.
To change the nickname of anyMember
for thisGuild
the PermissionNICKNAME_MANAGE
is required.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The nickname of the target Member is not modifiable due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Specified by:
modifyNickname
in interfaceGuild
- Parameters:
member
- TheMember
for which the nickname should be changed.nickname
- The new nickname of theMember
, providenull
or an empty String to reset the nickname- Returns:
AuditableRestAction
-
prune
Description copied from interface:Guild
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 useGuild.retrievePrunableMemberCount(int)
to determine how many Members would be pruned if you were to call this method.This might timeout when pruning many members with
wait=true
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The prune cannot finished due to a permission discrepancy
- Specified by:
prune
in interfaceGuild
- 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.
-
modifySecurityIncidents
@Nonnull public AuditableRestAction<Void> modifySecurityIncidents(@Nonnull SecurityIncidentActions incidents) Description copied from interface:Guild
Update the current guildsecurity incident actions
.
Security incident actions are used to temporarily disable features for the purpose of moderation.Possible
ErrorResponses
caused by the returnedRestAction
include the following:ErrorResponse.INVALID_FORM_BODY
If one of the provided timestamps is too far into the future
- Specified by:
modifySecurityIncidents
in interfaceGuild
- Parameters:
incidents
- The new security incidents- Returns:
AuditableRestAction
- See Also:
-
kick
Description copied from interface:Guild
Kicks aMember
from theGuild
.Note:
Guild.getMembers()
will still contain theUser
until Discord sends theGuildMemberRemoveEvent
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be kicked due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Specified by:
kick
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
for the user to kick. This can be a member or user instance orUser.fromId(long)
.- Returns:
AuditableRestAction
Kicks the provided Member from the current Guild
-
ban
@Nonnull public AuditableRestAction<Void> ban(@Nonnull UserSnowflake user, int duration, @Nonnull TimeUnit unit) Description copied from interface:Guild
Bans the user specified by the providedUserSnowflake
and deletes messages sent by the user based on thedeletionTimeframe
.
If you wish to ban a user without deleting any messages, providedeletionTimeframe
with a value of 0. To set a ban reason, useAuditableRestAction.reason(String)
.You can unban a user with
Guild.unban(UserReference)
.Note:
Guild.getMembers()
will still contain theUser's
Member
object (if the User was in the Guild) until Discord sends theGuildMemberRemoveEvent
.Examples
Banning a user without deleting any messages:
Banning a user and deleting messages from the past hour:guild.ban(user, 0, TimeUnit.SECONDS) .reason("Banned for rude behavior") .queue();
guild.ban(user, 1, TimeUnit.HOURS) .reason("Banned for spamming") .queue();
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyUNKNOWN_USER
The user does not exist
- Specified by:
ban
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
for the user to ban. This can be a member or user instance orUser.fromId(long)
.duration
- 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
- See Also:
-
ban
@Nonnull public AuditableRestAction<BulkBanResponse> ban(@Nonnull Collection<? extends UserSnowflake> users, @Nullable Duration deletionTime) Description copied from interface:Guild
Bans up to 200 of the provided users.
To set a ban reason, useAuditableRestAction.reason(String)
.The
BulkBanResponse
includes a list offailed users
, which is populated with users that could not be banned, for instance due to some internal server error or permission issues. This list of failed users also includes all users that were already banned.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be banned due to a permission discrepancyFAILED_TO_BAN_USERS
None of the users could be banned
- Specified by:
ban
in interfaceGuild
- 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
-
unban
Description copied from interface:Guild
Unbans the specifiedUserSnowflake
from this Guild.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be unbanned due to a permission discrepancyUNKNOWN_BAN
The specified User is not banned from the current GuildUNKNOWN_USER
The specified User does not exist
- Specified by:
unban
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
to unban. This can be a member or user instance orUser.fromId(long)
.- Returns:
AuditableRestAction
-
timeoutUntil
@Nonnull public AuditableRestAction<Void> timeoutUntil(@Nonnull UserSnowflake user, @Nonnull TemporalAccessor temporal) Description copied from interface:Guild
Puts the specified Member in time out in thisGuild
until the specified date.
While a Member is in time out, all permissions exceptVIEW_CHANNEL
andMESSAGE_HISTORY
are removed from them.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be put into time out due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Specified by:
timeoutUntil
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
to timeout. This can be a member or user instance orUser.fromId(long)
.temporal
- The time the specified Member will be released from time out- Returns:
AuditableRestAction
-
removeTimeout
Description copied from interface:Guild
Removes a time out from the specified Member in thisGuild
.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The time out cannot be removed due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the task
- Specified by:
removeTimeout
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
to timeout. This can be a member or user instance orUser.fromId(long)
.- Returns:
AuditableRestAction
-
deafen
Description copied from interface:Guild
Sets the Guild Deafened state of theMember
based on the provided boolean.Note: The Member's
GuildVoiceState.isGuildDeafened()
value won't change until JDA receives theGuildVoiceGuildDeafenEvent
event related to this change.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be deafened due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUSER_NOT_CONNECTED
The specified Member is not connected to a voice channel
- Specified by:
deafen
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
who'sGuildVoiceState
to change. This can be a member or user instance orUser.fromId(long)
.deafen
- Whether thisMember
should be deafened or undeafened.- Returns:
AuditableRestAction
-
mute
Description copied from interface:Guild
Sets the Guild Muted state of theMember
based on the provided boolean.Note: The Member's
GuildVoiceState.isGuildMuted()
value won't change until JDA receives theGuildVoiceGuildMuteEvent
event related to this change.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The target Member cannot be muted due to a permission discrepancyUNKNOWN_MEMBER
The specified Member was removed from the Guild before finishing the taskUSER_NOT_CONNECTED
The specified Member is not connected to a voice channel
- Specified by:
mute
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
who'sGuildVoiceState
to change. This can be a member or user instance orUser.fromId(long)
.mute
- Whether thisMember
should be muted or unmuted.- Returns:
AuditableRestAction
-
addRoleToMember
@Nonnull public AuditableRestAction<Void> addRoleToMember(@Nonnull UserSnowflake user, @Nonnull Role role) Description copied from interface:Guild
Atomically assigns the providedRole
to the specifiedMember
.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is already present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Specified by:
addRoleToMember
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
to change roles for. This can be a member or user instance orUser.fromId(long)
.role
- The role which should be assigned atomically- Returns:
AuditableRestAction
-
removeRoleFromMember
@Nonnull public AuditableRestAction<Void> removeRoleFromMember(@Nonnull UserSnowflake user, @Nonnull Role role) Description copied from interface:Guild
Atomically removes the providedRole
from the specifiedMember
.
This can be used together with other role modification methods as it does not require an updated cache!If multiple roles should be added/removed (efficiently) in one request you may use
modifyMemberRoles(Member, Collection, Collection)
or similar methods.If the specified role is not present in the member's set of roles this does nothing.
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the taskUNKNOWN_ROLE
If the specified Role does not exist
- Specified by:
removeRoleFromMember
in interfaceGuild
- Parameters:
user
- TheUserSnowflake
to change roles for. This can be a member or user instance orUser.fromId(long)
.role
- The role which should be removed atomically- Returns:
AuditableRestAction
-
modifyMemberRoles
@Nonnull public AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, Collection<Role> rolesToAdd, Collection<Role> rolesToRemove) Description copied from interface:Guild
Modifies theRoles
of the specifiedMember
by adding and removing a collection of roles.
None of the provided roles may be the Public Role of the current Guild.
If a role is both inrolesToAdd
androlesToRemove
it will be removed.Example
public static void promote(Member member) { Guild guild = member.getGuild(); List<Role> pleb = guild.getRolesByName("Pleb", true); // remove all roles named "pleb" List<Role> knight = guild.getRolesByName("Knight", true); // add all roles named "knight" // update roles in single request guild.modifyMemberRoles(member, knight, pleb).queue(); }
Warning
This may not be used together with any other role add/remove/modify methods for the same Member within one event listener cycle! The changes made by this require cache updates which are triggered by lifecycle events which are received later. This may only be called again once the specific Member has been updated by aGenericGuildMemberEvent
targeting the same Member.This is logically equivalent to:
Set<Role> roles = new HashSet<>(member.getRoles()); roles.addAll(rolesToAdd); roles.removeAll(rolesToRemove); RestAction<Void> action = guild.modifyMemberRoles(member, roles);
You can use
Guild.addRoleToMember(UserSnowflake, Role)
andGuild.removeRoleFromMember(UserSnowflake, Role)
to make updates independent of the cache.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
- Specified by:
modifyMemberRoles
in interfaceGuild
- Parameters:
member
- TheMember
that should be modifiedrolesToAdd
- ACollection
ofRoles
to add to the current Roles the specifiedMember
already has, or nullrolesToRemove
- ACollection
ofRoles
to remove from the current Roles the specifiedMember
already has, or null- Returns:
AuditableRestAction
-
modifyMemberRoles
@Nonnull public AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Nonnull Collection<Role> roles) Description copied from interface:Guild
Modifies the completeRole
set of the specifiedMember
The provided roles will replace all current Roles of the specified Member.The new roles must not contain the Public Role of the Guild
Warning
This may not be used together with any other role add/remove/modify methods for the same Member within one event listener cycle! The changes made by this require cache updates which are triggered by lifecycle events which are received later. This may only be called again once the specific Member has been updated by aGenericGuildMemberEvent
targeting the same Member.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The Members Roles could not be modified due to a permission discrepancyUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
Example
public static void makeModerator(Member member) { Guild guild = member.getGuild(); List<Role> roles = new ArrayList<>(member.getRoles()); // modifiable copy List<Role> modRoles = guild.getRolesByName("moderator", true); // get roles with name "moderator" roles.addAll(modRoles); // add new roles // update the member with new roles guild.modifyMemberRoles(member, roles).queue(); }
- Specified by:
modifyMemberRoles
in interfaceGuild
- Parameters:
member
- AMember
of which to override the Roles ofroles
- New collection ofRoles
for the specified Member- Returns:
AuditableRestAction
- See Also:
-
transferOwnership
Description copied from interface:Guild
Transfers the Guild ownership to the specifiedMember
Only available if the currently logged in account is the owner of this GuildPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The currently logged in account lost ownership before completing the taskUNKNOWN_MEMBER
The target Member was removed from the Guild before finishing the task
- Specified by:
transferOwnership
in interfaceGuild
- Parameters:
newOwner
- Not-null Member to transfer ownership to- Returns:
AuditableRestAction
-
createTextChannel
Description copied from interface:Guild
Creates a newTextChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
PermissionPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createTextChannel
in interfaceGuild
- 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
-
createNewsChannel
Description copied from interface:Guild
Creates a newNewsChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
PermissionPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createNewsChannel
in interfaceGuild
- 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
-
createVoiceChannel
@Nonnull public ChannelAction<VoiceChannel> createVoiceChannel(@Nonnull String name, Category parent) Description copied from interface:Guild
Creates a newVoiceChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createVoiceChannel
in interfaceGuild
- 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
-
createStageChannel
@Nonnull public ChannelAction<StageChannel> createStageChannel(@Nonnull String name, Category parent) Description copied from interface:Guild
Creates a newStageChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createStageChannel
in interfaceGuild
- 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
-
createForumChannel
@Nonnull public ChannelAction<ForumChannel> createForumChannel(@Nonnull String name, Category parent) Description copied from interface:Guild
Creates a newForumChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createForumChannel
in interfaceGuild
- 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
-
createMediaChannel
@Nonnull public ChannelAction<MediaChannel> createMediaChannel(@Nonnull String name, @Nullable Category parent) Description copied from interface:Guild
Creates a newMediaChannel
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createMediaChannel
in interfaceGuild
- 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
-
createCategory
Description copied from interface:Guild
Creates a newCategory
in this Guild. For this to be successful, the logged in account has to have theMANAGE_CHANNEL
Permission.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMAX_CHANNELS
The maximum number of channels were exceeded
- Specified by:
createCategory
in interfaceGuild
- 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
-
createRole
Description copied from interface:Guild
Creates a newRole
in this Guild.
It will be placed at the bottom (just over the Public Role) to avoid permission hierarchy conflicts.
For this to be successful, the logged in account has to have theMANAGE_ROLES
PermissionPossible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The role could not be created due to a permission discrepancyMAX_ROLES_PER_GUILD
There are too many roles in this Guild
- Specified by:
createRole
in interfaceGuild
- Returns:
RoleAction
Creates a new role with previously selected field values
-
createEmoji
@Nonnull public AuditableRestAction<RichCustomEmoji> createEmoji(@Nonnull String name, @Nonnull Icon icon, @Nonnull Role... roles) Description copied from interface:Guild
Creates a newRichCustomEmoji
in this Guild.
If one or more Roles are specified the new emoji will only be available to Members with any of the specified Roles (seeMember.canInteract(RichCustomEmoji)
)
For this to be successful, the logged in account has to have theMANAGE_GUILD_EXPRESSIONS
Permission.Unicode emojis are not included as
RichCustomEmoji
!Note that a guild is limited to 50 normal and 50 animated emojis by default. Some guilds are able to add additional emojis beyond this limitation due to the
MORE_EMOJI
feature (seeGuild.getFeatures()
).
Due to simplicity we do not check for these limits.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The emoji could not be created due to a permission discrepancy
- Specified by:
createEmoji
in interfaceGuild
- Parameters:
name
- The name for the new emojiicon
- TheIcon
for the new emojiroles
- TheRoles
the new emoji should be restricted to
If no roles are provided the emoji will be available to all Members of this Guild- Returns:
AuditableRestAction
- Type:RichCustomEmoji
-
createSticker
@Nonnull public AuditableRestAction<GuildSticker> createSticker(@Nonnull String name, @Nonnull String description, @Nonnull FileUpload file, @Nonnull Collection<String> tags) Description copied from interface:Guild
Creates a newGuildSticker
in this Guild.Possible
ErrorResponses
include:INVALID_FILE_UPLOADED
The sticker file asset is not in a supported file formatMISSING_PERMISSIONS
The sticker could not be created due to a permission discrepancy
- Specified by:
createSticker
in interfaceGuild
- 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
-
deleteSticker
Description copied from interface:Guild
Deletes a sticker from the guild.The returned
RestAction
can encounter the following Discord errors:UNKNOWN_STICKER
Occurs when the provided id does not refer to a sticker known by Discord.
- Specified by:
deleteSticker
in interfaceGuild
- Returns:
AuditableRestAction
-
modifyCategoryPositions
Description copied from interface:Guild
Modifies the positional order ofGuild.getCategories()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Specified by:
modifyCategoryPositions
in interfaceGuild
- Returns:
ChannelOrderAction
- Type:Category
-
modifyTextChannelPositions
Description copied from interface:Guild
Modifies the positional order ofGuild.getTextChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Specified by:
modifyTextChannelPositions
in interfaceGuild
- Returns:
ChannelOrderAction
- Type:TextChannel
-
modifyVoiceChannelPositions
Description copied from interface:Guild
Modifies the positional order ofGuild.getVoiceChannels()
using a specificRestAction
extension to allow moving Channelsup
/down
orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Specified by:
modifyVoiceChannelPositions
in interfaceGuild
- Returns:
ChannelOrderAction
- Type:VoiceChannel
-
modifyTextChannelPositions
Description copied from interface:Guild
Modifies the positional order ofCategory#getTextChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedTextChannels
of thisCategory
.
LikeChannelOrderAction
, the returnedCategoryOrderAction
can be used to move TextChannelsup
,down
, orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the task.MISSING_ACCESS
The currently logged in account was removed from the Guild.
- Specified by:
modifyTextChannelPositions
in interfaceGuild
- Parameters:
category
- TheCategory
to orderTextChannels
from.- Returns:
CategoryOrderAction
- Type:TextChannel
-
modifyVoiceChannelPositions
Description copied from interface:Guild
Modifies the positional order ofCategory#getVoiceChannels()
using an extension ofChannelOrderAction
specialized for ordering the nestedVoiceChannels
of thisCategory
.
LikeChannelOrderAction
, the returnedCategoryOrderAction
can be used to move VoiceChannelsup
,down
, orto
a specific position.
This uses ascending order with a 0 based index.Possible
ErrorResponses
include:UNNKOWN_CHANNEL
One of the channels has been deleted before the completion of the task.MISSING_ACCESS
The currently logged in account was removed from the Guild.
- Specified by:
modifyVoiceChannelPositions
in interfaceGuild
- Parameters:
category
- TheCategory
to orderVoiceChannels
from.- Returns:
CategoryOrderAction
- Type:VoiceChannels
-
modifyRolePositions
Description copied from interface:Guild
Modifies the positional order ofGuild.getRoles()
using a specificRestAction
extension to allow moving Rolesup
/down
orto
a specific position.Possible
ErrorResponses
include:UNKNOWN_ROLE
One of the roles was deleted before the completion of the taskMISSING_ACCESS
The currently logged in account was removed from the Guild
- Specified by:
modifyRolePositions
in interfaceGuild
- Parameters:
useAscendingOrder
- Defines the ordering of the OrderAction. Iffalse
, the OrderAction will be in the ordering defined by Discord for roles, which is Descending. This means that the highest role appears at index0
and the lowest role at indexn - 1
. Providingtrue
will result in the ordering being in ascending order, with the lower role at index0
and the highest at indexn - 1
.
As a note:Member.getRoles()
andGuild.getRoles()
are both in descending order.- Returns:
RoleOrderAction
-
modifyWelcomeScreen
Description copied from interface:Guild
TheManager
for this guild's welcome screen, used to modify properties of the welcome screen like if the welcome screen is enabled, the description and welcome channels.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Specified by:
modifyWelcomeScreen
in interfaceGuild
- Returns:
- The GuildWelcomeScreenManager for this guild's welcome screen
-
updateRequestToSpeak
public void updateRequestToSpeak() -
setOwner
-
setName
-
setIconId
-
setFeatures
-
setSplashId
-
setVanityCode
-
setDescription
-
setBannerId
-
setMaxPresences
-
setMaxMembers
-
setAfkChannel
-
setSystemChannel
-
setRulesChannel
-
setCommunityUpdatesChannel
-
setSafetyAlertsChannel
-
setPublicRole
-
setSecurityIncidentActions
-
setSecurityIncidentDetections
-
setVerificationLevel
-
setDefaultNotificationLevel
-
setRequiredMFALevel
-
setExplicitContentLevel
-
setAfkTimeout
-
setLocale
-
setBoostTier
-
setBoostCount
-
setOwnerId
-
setMemberCount
-
setNSFWLevel
-
setBoostProgressBarEnabled
-
getScheduledEventsView
-
getChannelView
-
getRolesView
-
getEmojisView
-
getStickersView
-
getMembersView
-
getNSFWLevel
Description copied from interface:Guild
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.
- Specified by:
getNSFWLevel
in interfaceGuild
- Returns:
- The NSFWLevel of this guild.
-
getPresenceView
-
getVoiceStateView
-
onMemberAdd
public void onMemberAdd() -
onMemberRemove
public void onMemberRemove(long memberId) -
shouldCacheVoiceState
public boolean shouldCacheVoiceState(long userId) -
getVoiceState
-
updateCacheVoiceStateMember
-
handleVoiceStateUpdate
-
getConnectedMembers
-
equals
-
hashCode
public int hashCode() -
toString
-