Package net.dv8tion.jda.core.entities
Interface Channel
-
- All Superinterfaces:
ISnowflake
- All Known Subinterfaces:
Category
,TextChannel
,VoiceChannel
public interface Channel extends ISnowflake
Represents aGuild
channel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ChannelAction
createCopy()
Creates a copy of the specifiedChannel
.ChannelAction
createCopy(Guild guild)
InviteAction
createInvite()
Creates a newInviteAction
which can be used to create a newInvite
.PermissionOverrideAction
createPermissionOverride(Member member)
Creates aPermissionOverride
for the specifiedMember
in this Channel.PermissionOverrideAction
createPermissionOverride(Role role)
Creates aPermissionOverride
for the specifiedRole
in this Channel.AuditableRestAction<java.lang.Void>
delete()
Deletes this Channel.Guild
getGuild()
Returns theGuild
that this Channel is part of.RestAction<java.util.List<Invite>>
getInvites()
Returns all invites for this channel.JDA
getJDA()
Returns theJDA
instance of this ChannelChannelManager
getManager()
Returns theChannelManager
for this Channel.java.util.List<PermissionOverride>
getMemberPermissionOverrides()
java.util.List<Member>
getMembers()
A List of allMembers
that are in this Channel ForTextChannels
, this returns all Members with thePermission.MESSAGE_READ
Permission.java.lang.String
getName()
The human readable name of the Channel.Category
getParent()
ParentCategory
of this Channel.PermissionOverride
getPermissionOverride(Member member)
ThePermissionOverride
relating to the specifiedMember
.PermissionOverride
getPermissionOverride(Role role)
ThePermissionOverride
relating to the specifiedRole
.java.util.List<PermissionOverride>
getPermissionOverrides()
Gets all of thePermissionOverrides
that are part of thisChannel
.int
getPosition()
The position this Channel is displayed at.int
getPositionRaw()
The actual position of theChannel
as stored and given by Discord.java.util.List<PermissionOverride>
getRolePermissionOverrides()
ChannelType
getType()
TheChannelType
for this ChannelPermissionOverrideAction
putPermissionOverride(Member member)
Creates aPermissionOverride
for the specifiedMember
in this Channel.PermissionOverrideAction
putPermissionOverride(Role role)
Creates aPermissionOverride
for the specifiedRole
in this Channel.-
Methods inherited from interface net.dv8tion.jda.core.entities.ISnowflake
getCreationTime, getId, getIdLong
-
-
-
-
Method Detail
-
getType
ChannelType getType()
TheChannelType
for this Channel- Returns:
- The channel type
-
getName
java.lang.String getName()
The human readable name of the Channel.
If no name has been set, this returns null.- Returns:
- The name of this Channel
-
getGuild
Guild getGuild()
Returns theGuild
that this Channel is part of.- Returns:
- Never-null
Guild
that this Channel is part of.
-
getParent
Category getParent()
ParentCategory
of this Channel. 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 Channel
-
getMembers
java.util.List<Member> getMembers()
A List of allMembers
that are in this Channel ForTextChannels
, this returns all Members with thePermission.MESSAGE_READ
Permission. InVoiceChannels
, this returns all Members that joined that VoiceChannel.- Returns:
- A List of
Members
that are in this Channel.
-
getPosition
int getPosition()
The position this Channel is displayed at.
Higher values mean they are displayed lower in the Client. Position 0 is the top most Channel Channels of aGuild
do not have to have continuous positions- Returns:
- Zero-based int of position of the Channel.
-
getPositionRaw
int getPositionRaw()
The actual position of theChannel
as stored and given by Discord. Role positions are actually based on a pairing of the creation time (as stored in the snowflake id) and the position. If 2 or more roles share the same position then they are sorted based on their creation date. The more recent a role 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 Role then this method will give you that value.- Returns:
- The true, Discord stored, position of the
Channel
.
-
getJDA
JDA getJDA()
Returns theJDA
instance of this Channel- Returns:
- the corresponding JDA instance
-
getPermissionOverride
PermissionOverride getPermissionOverride(Member member)
ThePermissionOverride
relating to the specifiedMember
. If there is noPermissionOverride
for thisChannel
relating to the providedMember
, then this returnsnull
.- Parameters:
member
- TheMember
whosePermissionOverride
is requested.- Returns:
- Possibly-null
PermissionOverride
relating to the providedMember
.
-
getPermissionOverride
PermissionOverride getPermissionOverride(Role role)
ThePermissionOverride
relating to the specifiedRole
. If there is noPermissionOverride
for thisChannel
relating to the providedRole
, then this returnsnull
.- Parameters:
role
- TheRole
whosePermissionOverride
is requested.- Returns:
- Possibly-null
PermissionOverride
relating to the providedRole
.
-
getPermissionOverrides
java.util.List<PermissionOverride> getPermissionOverrides()
Gets all of thePermissionOverrides
that are part of thisChannel
.
This combinesMember
andRole
overrides. If you would like onlyMember
overrides or onlyRole
overrides, usegetMemberPermissionOverrides()
orgetRolePermissionOverrides()
respectively.- Returns:
- Possibly-empty list of all
PermissionOverrides
for thisChannel
.
-
getMemberPermissionOverrides
java.util.List<PermissionOverride> getMemberPermissionOverrides()
- Returns:
- Possibly-empty list of all
PermissionOverrides
forMember
for thisChannel
.
-
getRolePermissionOverrides
java.util.List<PermissionOverride> getRolePermissionOverrides()
- Returns:
- Possibly-empty list of all
PermissionOverrides
forRoles
for thisChannel
.
-
createCopy
@CheckReturnValue ChannelAction createCopy(Guild guild)
Creates a copy of the specifiedChannel
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)
- 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
We were removed from the Guild before finishing the task
- Parameters:
guild
- TheGuild
to create the channel in- Returns:
- A specific
ChannelAction
This action allows to set fields for the new Channel before creating it! - Throws:
java.lang.IllegalArgumentException
- If the provided guild isnull
PermissionException
- If the currently logged in account does not have theMANAGE_CHANNEL
Permission
-
createCopy
@CheckReturnValue default ChannelAction createCopy()
Creates a copy of the specifiedChannel
.This copies the following elements:
- Name
- Parent Category (if present)
- Voice Elements (Bitrate, Userlimit)
- Text Elements (Topic, NSFW)
- All permission overrides for Members/Roles
Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
The channel could not be created due to a permission discrepancyMISSING_ACCESS
We were removed from the Guild before finishing the task
- Returns:
- A specific
ChannelAction
This action allows to set fields for the new Channel before creating it! - Throws:
PermissionException
- If the currently logged in account does not have theMANAGE_CHANNEL
Permission
-
getManager
ChannelManager getManager()
Returns theChannelManager
for this Channel.
In the ChannelManager, you can modify the name, topic and position of this Channel. You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The ChannelManager of this Channel
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_CHANNEL
-
delete
@CheckReturnValue AuditableRestAction<java.lang.Void> delete()
Deletes this Channel.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
@CheckReturnValue PermissionOverrideAction createPermissionOverride(Member member)
Creates aPermissionOverride
for the specifiedMember
in this Channel. You can useputPermissionOverride(Member)
to replace existing overrides.Possible ErrorResponses include:
UNKNOWN_CHANNEL
If this channel was already deletedMISSING_ACCESS
If we were removed from the Guild
- Parameters:
member
- The Member to create an override for- Returns:
PermissionOverrideAction
Provides the newly created PermissionOverride for the specified Role- Throws:
InsufficientPermissionException
- if we don't have the permission toMANAGE_PERMISSIONS
java.lang.IllegalArgumentException
- if the specified Member is null or the Member is not fromgetGuild()
java.lang.IllegalStateException
- If the specified Member already has a PermissionOverride. UsegetPermissionOverride(Member)
to retrieve it. You can useputPermissionOverride(Member)
to replace existing overrides.- See Also:
createPermissionOverride(Role)
,putPermissionOverride(Member)
-
createPermissionOverride
@CheckReturnValue PermissionOverrideAction createPermissionOverride(Role role)
Creates aPermissionOverride
for the specifiedRole
in this Channel. You can useputPermissionOverride(Role)
to replace existing overrides.Possible ErrorResponses include:
UNKNOWN_CHANNEL
If this channel was already deletedMISSING_ACCESS
If we were removed from the Guild
- Parameters:
role
- The Role to create an override for- Returns:
PermissionOverrideAction
Provides the newly created PermissionOverride for the specified Role- Throws:
InsufficientPermissionException
- if we don't have the permission toMANAGE_PERMISSIONS
java.lang.IllegalArgumentException
- if the specified Role is null or the Role is not fromgetGuild()
java.lang.IllegalStateException
- If the specified Role already has a PermissionOverride. UsegetPermissionOverride(Role)
to retrieve it. You can useputPermissionOverride(Role)
to replace existing overrides.- See Also:
createPermissionOverride(Member)
,putPermissionOverride(Role)
-
putPermissionOverride
@CheckReturnValue PermissionOverrideAction putPermissionOverride(Member member)
Creates aPermissionOverride
for the specifiedMember
in this Channel.
If the member already has an existing override it will be replaced.- Parameters:
member
- The Member to create the override for- Returns:
PermissionOverrideAction
Provides the newly created PermissionOverride for the specified Member- Throws:
InsufficientPermissionException
- if we don't have the permission toMANAGE_PERMISSIONS
java.lang.IllegalArgumentException
- If the provided member is null or from a different guild- See Also:
putPermissionOverride(Role)
-
putPermissionOverride
@CheckReturnValue PermissionOverrideAction putPermissionOverride(Role role)
Creates aPermissionOverride
for the specifiedRole
in this Channel.
If the role already has an existing override it will be replaced.- Parameters:
role
- The Role to create the override for- Returns:
PermissionOverrideAction
Provides the newly created PermissionOverride for the specified Role- Throws:
InsufficientPermissionException
- if we don't have the permission toMANAGE_PERMISSIONS
java.lang.IllegalArgumentException
- If the provided role is null or from a different guild- See Also:
putPermissionOverride(Member)
-
createInvite
@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 channeljava.lang.IllegalArgumentException
- If this is an instance of aCategory
- See Also:
InviteAction
-
getInvites
@CheckReturnValue RestAction<java.util.List<Invite>> getInvites()
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.getInvites()
-
-