Interface IPositionableChannel
- All Superinterfaces:
Channel
,Comparable<GuildChannel>
,Formattable
,GuildChannel
,IMentionable
,ISnowflake
- All Known Subinterfaces:
AudioChannel
,AudioChannelUnion
,Category
,DefaultGuildChannelUnion
,ForumChannel
,ICategorizableChannel
,MediaChannel
,NewsChannel
,StageChannel
,StandardGuildChannel
,StandardGuildMessageChannel
,TextChannel
,VoiceChannel
GuildChannel
that has a position.
These channels can be re-ordered using a position value.
In the case of identical position values, the natural order of the channel snowflakes is used.
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.channel.Channel
MAX_NAME_LENGTH
Fields inherited from interface net.dv8tion.jda.api.entities.channel.middleman.GuildChannel
JUMP_URL
-
Method Summary
Modifier and TypeMethodDescriptionReturns theChannelManager
for this GuildChannel.default int
The position of this channel in the channel list of the guild.int
The actual position of theGuildChannel
as stored and given by Discord.Methods inherited from interface net.dv8tion.jda.api.entities.channel.Channel
formatTo, getAsMention, getFlags, getJDA, getName, getType
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface net.dv8tion.jda.api.entities.channel.middleman.GuildChannel
delete, getGuild, getJumpUrl, getPermissionContainer
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
Method Details
-
getManager
Description copied from interface:GuildChannel
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()
.- Specified by:
getManager
in interfaceGuildChannel
- Returns:
- The ChannelManager of this GuildChannel
-
getPosition
default int getPosition()The position of this channel in the channel list of the guild.
This does not account for thread channels, as they do not have positions.This is functionally equivalent to
getGuild().getChannels().indexOf(channel)
. To efficiently compare the position between channels, it is recommended to useComparable.compareTo(Object)
instead of the position.- Returns:
- Zero-based int of position of the GuildChannel.
- Throws:
IllegalStateException
- If this channel is not in the guild cache
-
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 by
getPosition()
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
.
-