Interface GuildChannel
-
- All Superinterfaces:
AbstractChannel,java.lang.Comparable<GuildChannel>,java.util.Formattable,IMentionable,ISnowflake
- All Known Subinterfaces:
Category,StageChannel,StoreChannel,TextChannel,VoiceChannel
public interface GuildChannel extends AbstractChannel, IMentionable, java.lang.Comparable<GuildChannel>
Represents aGuildchannel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ChannelAction<? extends GuildChannel>createCopy()Creates a copy of the specifiedGuildChannel.ChannelAction<? extends GuildChannel>createCopy(Guild guild)Creates a copy of the specifiedGuildChannelin the specifiedGuild.InviteActioncreateInvite()Creates a newInviteActionwhich can be used to create a newInvite.PermissionOverrideActioncreatePermissionOverride(IPermissionHolder permissionHolder)AuditableRestAction<java.lang.Void>delete()Deletes this GuildChannel.GuildgetGuild()Returns theGuildthat this GuildChannel is part of.ChannelManagergetManager()Returns theChannelManagerfor this GuildChannel.java.util.List<PermissionOverride>getMemberPermissionOverrides()java.util.List<Member>getMembers()A List of allMembersthat are in this GuildChannel
ForTextChannels, this returns all Members with thePermission.MESSAGE_READPermission.CategorygetParent()ParentCategoryof this GuildChannel.PermissionOverridegetPermissionOverride(IPermissionHolder permissionHolder)java.util.List<PermissionOverride>getPermissionOverrides()Gets all of thePermissionOverridesthat are part of thisGuildChannel.intgetPosition()The position this GuildChannel is displayed at.intgetPositionRaw()The actual position of theGuildChannelas stored and given by Discord.java.util.List<PermissionOverride>getRolePermissionOverrides()booleanisSynced()Whether or not this GuildChannel'sPermissionOverridesmatch those ofits parent category.PermissionOverrideActionputPermissionOverride(IPermissionHolder permissionHolder)RestAction<java.util.List<Invite>>retrieveInvites()Returns all invites for this channel.default PermissionOverrideActionupsertPermissionOverride(IPermissionHolder permissionHolder)Creates a new override or updates an existing one.-
Methods inherited from interface net.dv8tion.jda.api.entities.AbstractChannel
getJDA, getName, getType
-
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo, getAsMention
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getGuild
@Nonnull Guild getGuild()
Returns theGuildthat this GuildChannel is part of.- Returns:
- Never-null
Guildthat this GuildChannel is part of.
-
getParent
@Nullable Category getParent()
ParentCategoryof this GuildChannel. Channels don't need to have a parent Category.
Note that aCategorywill always returnnullfor this method as nested categories are not supported.- Returns:
- Possibly-null
Categoryfor this GuildChannel
-
getMembers
@Nonnull java.util.List<Member> getMembers()
A List of allMembersthat are in this GuildChannel
ForTextChannels, this returns all Members with thePermission.MESSAGE_READPermission.
ForVoiceChannels, this returns all Members that joined that VoiceChannel.
ForCategories, this returns all Members who are in its child channels.- Returns:
- An immutable List of
Membersthat are in this GuildChannel.
-
getPosition
int getPosition()
The position this GuildChannel is displayed at.
Higher values mean they are displayed lower in the Client. Position 0 is the top most GuildChannel Channels of aGuilddo not have to have continuous positions- Returns:
- Zero-based int of position of the GuildChannel.
- Throws:
java.lang.IllegalStateException- If this channel is not in the guild cache
-
getPositionRaw
int getPositionRaw()
The actual position of theGuildChannelas stored and given by Discord. Channel positions are actually based on a pairing of the creation time (as stored in the snowflake id) and the position. If 2 or more channels share the same position then they are sorted based on their creation date. The more recent a channel was created, the lower it is in the hierarchy. This is handled bygetPosition()and it is most likely the method you want. If, for some reason, you want the actual position of the channel then this method will give you that value.- Returns:
- The true, Discord stored, position of the
GuildChannel.
-
getPermissionOverride
@Nullable PermissionOverride getPermissionOverride(@Nonnull IPermissionHolder permissionHolder)
ThePermissionOverriderelating to the specifiedMemberorRole. If there is noPermissionOverridefor thisGuildChannelrelating to the provided Member or Role, then this returnsnull.- Parameters:
permissionHolder- TheMemberorRolewhosePermissionOverrideis requested.- Returns:
- Possibly-null
PermissionOverriderelating to the provided Member or Role. - Throws:
java.lang.IllegalArgumentException- If the provided permission holder is null, or from a different guild
-
getPermissionOverrides
@Nonnull java.util.List<PermissionOverride> getPermissionOverrides()
Gets all of thePermissionOverridesthat are part of thisGuildChannel.
This combinesMemberandRoleoverrides. If you would like onlyMemberoverrides or onlyRoleoverrides, usegetMemberPermissionOverrides()orgetRolePermissionOverrides()respectively.This requires
CacheFlag.MEMBER_OVERRIDESto be enabled! Without that CacheFlag, this list will only contain overrides for the currently logged in account and roles.- Returns:
- Possibly-empty immutable list of all
PermissionOverridesfor thisGuildChannel.
-
getMemberPermissionOverrides
@Nonnull java.util.List<PermissionOverride> getMemberPermissionOverrides()
Gets all of theMemberPermissionOverridesthat are part of thisGuildChannel.This requires
CacheFlag.MEMBER_OVERRIDESto be enabled!- Returns:
- Possibly-empty immutable list of all
PermissionOverridesforMemberfor thisGuildChannel.
-
getRolePermissionOverrides
@Nonnull java.util.List<PermissionOverride> getRolePermissionOverrides()
- Returns:
- Possibly-empty immutable list of all
PermissionOverridesforRolesfor thisGuildChannel.
-
isSynced
boolean isSynced()
Whether or not this GuildChannel'sPermissionOverridesmatch those ofits parent category. If the channel doesn't have a parent category, this will return true.This requires
CacheFlag.MEMBER_OVERRIDESto be enabled.createLight(String)disables this CacheFlag by default.- Returns:
- True, if this channel is synced with its parent category
- Since:
- 4.2.1
-
createCopy
@Nonnull @CheckReturnValue ChannelAction<? extends GuildChannel> createCopy(@Nonnull Guild guild)
Creates a copy of the specifiedGuildChannelin the specifiedGuild.
If the provided target guild is not the same Guild this channel is in then the parent category and permissions will not be copied due to technical difficulty and ambiguity.This copies the following elements:
- Name
- Parent Category (if present)
- Voice Elements (Bitrate, Userlimit)
- Text Elements (Topic, NSFW, Slowmode)
- All permission overrides for Members/Roles
Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNELpermission was removed
- Parameters:
guild- TheGuildto create the channel in- Returns:
- A specific
ChannelAction
This action allows to set fields for the new GuildChannel before creating it! - Throws:
java.lang.IllegalArgumentException- If the provided guild isnullPermissionException- If the currently logged in account does not have theMANAGE_CHANNELPermission
-
createCopy
@Nonnull @CheckReturnValue default ChannelAction<? extends GuildChannel> createCopy()
Creates a copy of the specifiedGuildChannel.This copies the following elements:
- Name
- Parent Category (if present)
- Voice Elements (Bitrate, Userlimit)
- Text Elements (Topic, NSFW, Slowmode)
- All permission overrides for Members/Roles
Possible
ErrorResponsescaused by the returnedRestActioninclude the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNELpermission was removed
- Returns:
- A specific
ChannelAction
This action allows to set fields for the new GuildChannel before creating it! - Throws:
PermissionException- If the currently logged in account does not have theMANAGE_CHANNELPermission
-
getManager
@Nonnull ChannelManager getManager()
Returns theChannelManagerfor this GuildChannel.
In the ChannelManager, you can modify the name, topic and position of this GuildChannel. You modify multiple fields in one request by chaining setters before callingRestAction.queue().This is a lazy idempotent getter. The manager is retained after the first call. This getter is not thread-safe and would require guards by the user.
- Returns:
- The ChannelManager of this GuildChannel
- Throws:
InsufficientPermissionException- If the currently logged in account does not havePermission.MANAGE_CHANNEL
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<java.lang.Void> delete()
Deletes this GuildChannel.Possible ErrorResponses include:
UNKNOWN_CHANNEL
If this channel was already deletedMISSING_PERMISSIONS
The send request was attempted after the account lostPermission.MANAGE_CHANNELin the channel.MISSING_ACCESS
If we were removed from the Guild
- Returns:
AuditableRestAction- Throws:
InsufficientPermissionException- if the currently logged in account doesn't haveMANAGE_CHANNELfor the channel.
-
createPermissionOverride
@Nonnull @CheckReturnValue PermissionOverrideAction createPermissionOverride(@Nonnull IPermissionHolder permissionHolder)
Creates aPermissionOverridefor the specifiedMemberorRolein this GuildChannel. You can useputPermissionOverride(IPermissionHolder)to replace existing overrides.Possible ErrorResponses include:
UNKNOWN_CHANNEL
If this channel was already deletedMISSING_ACCESS
If we were removed from the Guild
- Parameters:
permissionHolder- The Member or Role to create an override for- Returns:
PermissionOverrideActionProvides the newly created PermissionOverride for the specified permission holder- Throws:
InsufficientPermissionException- if we don't have the permission toMANAGE_PERMISSIONSjava.lang.IllegalArgumentException- if the specified permission holder is null or is not fromgetGuild()java.lang.IllegalStateException- If the specified permission holder already has a PermissionOverride. UsegetPermissionOverride(IPermissionHolder)to retrieve it. You can useputPermissionOverride(IPermissionHolder)to replace existing overrides.
-
putPermissionOverride
@Nonnull @CheckReturnValue PermissionOverrideAction putPermissionOverride(@Nonnull IPermissionHolder permissionHolder)
Creates aPermissionOverridefor the specifiedMemberorRolein this GuildChannel.
If the permission holder already has an existing override it will be replaced.- Parameters:
permissionHolder- The Member or Role to create the override for- Returns:
PermissionOverrideActionProvides the newly created PermissionOverride for the specified permission holder- Throws:
InsufficientPermissionException- if we don't have the permission toMANAGE_PERMISSIONSjava.lang.IllegalArgumentException- If the provided permission holder is null or from a different guild
-
upsertPermissionOverride
@Nonnull @CheckReturnValue default PermissionOverrideAction upsertPermissionOverride(@Nonnull IPermissionHolder permissionHolder)
Creates a new override or updates an existing one.
This is similar to callingPermissionOverride.getManager()if an override exists.- Parameters:
permissionHolder- The Member/Role for the override- Returns:
PermissionOverrideAction
With the current settings of an existing override or a fresh override with no permissions set- Throws:
InsufficientPermissionException- If we don't have the permission toMANAGE_PERMISSIONSjava.lang.IllegalArgumentException- If the provided permission holder is null or not from this guild- Since:
- 4.0.0
-
createInvite
@Nonnull @CheckReturnValue InviteAction createInvite()
Creates a newInviteActionwhich can be used to create a newInvite.
RequiresCREATE_INSTANT_INVITEin this channel.- Returns:
- A new
InviteAction - Throws:
InsufficientPermissionException- If the account does not haveCREATE_INSTANT_INVITEin this channeljava.lang.IllegalArgumentException- If this is an instance of aCategory- See Also:
InviteAction
-
retrieveInvites
@Nonnull @CheckReturnValue RestAction<java.util.List<Invite>> retrieveInvites()
Returns all invites for this channel.
RequiresMANAGE_CHANNELin this channel. Will throw anInsufficientPermissionExceptionotherwise.- Returns:
RestAction- Type: List<Invite>
The list of expanded Invite objects- Throws:
InsufficientPermissionException- if the account does not haveMANAGE_CHANNELin this channel- See Also:
Guild.retrieveInvites()
-
-