Package net.dv8tion.jda.api.entities
Interface GuildChannel
-
- All Superinterfaces:
Comparable<GuildChannel>
,ISnowflake
- All Known Subinterfaces:
Category
,StoreChannel
,TextChannel
,VoiceChannel
public interface GuildChannel extends ISnowflake, Comparable<GuildChannel>
Represents aGuild
channel.
-
-
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 specifiedGuildChannel
in the specifiedGuild
.InviteAction
createInvite()
Creates a newInviteAction
which can be used to create a newInvite
.PermissionOverrideAction
createPermissionOverride(IPermissionHolder permissionHolder)
AuditableRestAction<Void>
delete()
Deletes this GuildChannel.Guild
getGuild()
Returns theGuild
that this GuildChannel is part of.JDA
getJDA()
Returns theJDA
instance of this GuildChannelChannelManager
getManager()
Returns theChannelManager
for this GuildChannel.List<PermissionOverride>
getMemberPermissionOverrides()
List<Member>
getMembers()
A List of allMembers
that are in this GuildChannel
ForTextChannels
, this returns all Members with thePermission.MESSAGE_READ
Permission.String
getName()
The human readable name of the GuildChannel.Category
getParent()
ParentCategory
of this GuildChannel.PermissionOverride
getPermissionOverride(IPermissionHolder permissionHolder)
List<PermissionOverride>
getPermissionOverrides()
Gets all of thePermissionOverrides
that are part of thisGuildChannel
.int
getPosition()
The position this GuildChannel is displayed at.int
getPositionRaw()
The actual position of theGuildChannel
as stored and given by Discord.List<PermissionOverride>
getRolePermissionOverrides()
ChannelType
getType()
TheChannelType
for this GuildChannelPermissionOverrideAction
putPermissionOverride(IPermissionHolder permissionHolder)
RestAction<List<Invite>>
retrieveInvites()
Returns all invites for this channel.default PermissionOverrideAction
upsertPermissionOverride(IPermissionHolder permissionHolder)
Creates a new override or updates an existing one.-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Method Detail
-
getType
@Nonnull ChannelType getType()
TheChannelType
for this GuildChannel- Returns:
- The channel type
-
getName
@Nonnull String getName()
The human readable name of the GuildChannel.
If no name has been set, this returns null.- Returns:
- The name of this GuildChannel
-
getGuild
@Nonnull Guild getGuild()
Returns theGuild
that this GuildChannel is part of.- Returns:
- Never-null
Guild
that this GuildChannel is part of.
-
getParent
@Nullable Category getParent()
ParentCategory
of this GuildChannel. Channels need not have a parent Category.
Note that anCategory
will always returnnull
for this method as nested categories are not supported.- Returns:
- Possibly-null
Category
for this GuildChannel
-
getMembers
@Nonnull List<Member> getMembers()
A List of allMembers
that are in this GuildChannel
ForTextChannels
, this returns all Members with thePermission.MESSAGE_READ
Permission.
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
Members
that 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 aGuild
do not have to have continuous positions- Returns:
- Zero-based int of position of the GuildChannel.
-
getPositionRaw
int getPositionRaw()
The actual position of theGuildChannel
as 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
.
-
getJDA
@Nonnull JDA getJDA()
Returns theJDA
instance of this GuildChannel- Returns:
- the corresponding JDA instance
-
getPermissionOverride
@Nullable PermissionOverride getPermissionOverride(@Nonnull IPermissionHolder permissionHolder)
ThePermissionOverride
relating to the specifiedMember
orRole
. If there is noPermissionOverride
for thisGuildChannel
relating to the provided Member or Role, then this returnsnull
.- Parameters:
permissionHolder
- TheMember
orRole
whosePermissionOverride
is requested.- Returns:
- Possibly-null
PermissionOverride
relating to the provided Member or Role. - Throws:
IllegalArgumentException
- If the provided permission holder is null, or from a different guild
-
getPermissionOverrides
@Nonnull List<PermissionOverride> getPermissionOverrides()
Gets all of thePermissionOverrides
that are part of thisGuildChannel
.
This combinesMember
andRole
overrides. If you would like onlyMember
overrides or onlyRole
overrides, usegetMemberPermissionOverrides()
orgetRolePermissionOverrides()
respectively.- Returns:
- Possibly-empty immutable list of all
PermissionOverrides
for thisGuildChannel
.
-
getMemberPermissionOverrides
@Nonnull List<PermissionOverride> getMemberPermissionOverrides()
- Returns:
- Possibly-empty immutable list of all
PermissionOverrides
forMember
for thisGuildChannel
.
-
getRolePermissionOverrides
@Nonnull List<PermissionOverride> getRolePermissionOverrides()
- Returns:
- Possibly-empty immutable list of all
PermissionOverrides
forRoles
for thisGuildChannel
.
-
createCopy
@Nonnull @CheckReturnValue ChannelAction<? extends GuildChannel> createCopy(@Nonnull Guild guild)
Creates a copy of the specifiedGuildChannel
in 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
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission was removed
- Parameters:
guild
- TheGuild
to create the channel in- Returns:
- A specific
ChannelAction
This action allows to set fields for the new GuildChannel before creating it! - Throws:
IllegalArgumentException
- If the provided guild isnull
PermissionException
- If the currently logged in account does not have theMANAGE_CHANNEL
Permission
-
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
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
TheVIEW_CHANNEL
permission 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_CHANNEL
Permission
-
getManager
@Nonnull ChannelManager getManager()
Returns theChannelManager
for 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()
.- Returns:
- The ChannelManager of this GuildChannel
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_CHANNEL
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<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_CHANNEL
in the channel.MISSING_ACCESS
If we were removed from the Guild
- Returns:
AuditableRestAction
- Throws:
InsufficientPermissionException
- if the currently logged in account doesn't haveMANAGE_CHANNEL
for the channel.
-
createPermissionOverride
@Nonnull @CheckReturnValue PermissionOverrideAction createPermissionOverride(@Nonnull IPermissionHolder permissionHolder)
Creates aPermissionOverride
for the specifiedMember
orRole
in 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:
PermissionOverrideAction
Provides the newly created PermissionOverride for the specified permission holder- Throws:
InsufficientPermissionException
- if we don't have the permission toMANAGE_PERMISSIONS
IllegalArgumentException
- if the specified permission holder is null or is not fromgetGuild()
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 aPermissionOverride
for the specifiedMember
orRole
in 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:
PermissionOverrideAction
Provides the newly created PermissionOverride for the specified permission holder- Throws:
InsufficientPermissionException
- if we don't have the permission toMANAGE_PERMISSIONS
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_PERMISSIONS
IllegalArgumentException
- If the provided permission holder is null or not from this guild- Since:
- 4.0.0
-
createInvite
@Nonnull @CheckReturnValue InviteAction createInvite()
Creates a newInviteAction
which can be used to create a newInvite
.
RequiresCREATE_INSTANT_INVITE
in this channel.- Returns:
- A new
InviteAction
- Throws:
InsufficientPermissionException
- If the account does not haveCREATE_INSTANT_INVITE
in this channelIllegalArgumentException
- If this is an instance of aCategory
- See Also:
InviteAction
-
retrieveInvites
@Nonnull @CheckReturnValue RestAction<List<Invite>> retrieveInvites()
Returns all invites for this channel.
RequiresMANAGE_CHANNEL
in this channel. Will throw aInsufficientPermissionException
otherwise.- Returns:
RestAction
- Type: List<Invite
>
The list of expanded Invite objects- Throws:
InsufficientPermissionException
- if the account does not haveMANAGE_CHANNEL
in this channel- See Also:
Guild.retrieveInvites()
-
-