Class OrderUtil
roles
and guild channels
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator<CategorizableChannel>
The ordering ofguild channels
which considers channel type.static final Comparator<TopLevelGuildChannel>
The base ordering of Discordguild channels
.static final Comparator<Role>
The ordering of Discordroles
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Flux<GuildChannel>
orderGuildChannels
(Flux<GuildChannel> channels) Sortsguild channels
according to visual ordering in Discord.orderRoles
(Flux<Role> roles) Sortsroles
according to visual ordering in Discord.
-
Field Details
-
ROLE_ORDER
-
CHANNEL_ORDER
The base ordering of Discordguild channels
.In Discord, two orderable entities may have the same "raw position," the position as reported by the "position" field. This conflict is resolved by comparing the creation time of the entities, reflected in their
IDs
.Note that this order is only applicable to channels if they are of the same type and in the same category. See
BUCKETED_CHANNEL_ORDER
for ordering between different channel types. -
BUCKETED_CHANNEL_ORDER
The ordering ofguild channels
which considers channel type.Guild channels are first ordered by "bucket" which is determined by the type of the channels. Then,
CHANNEL_ORDER
is used to determine order within a buvket. Effectively, this only means that voice channels always appear below other types of channels.Note that this order is only applicable to channels if they are in the same category.
-
-
Constructor Details
-
OrderUtil
public OrderUtil()
-
-
Method Details
-
orderGuildChannels
Sortsguild channels
according to visual ordering in Discord. Channels at the top of the list are first. This sorts channels within the same category according toBUCKETED_CHANNEL_ORDER
and then sorts those categories according toCHANNEL_ORDER
.This function can be used with
Flux.transform(Function)
for better chaining:guild.getChannels() .transform(OrderUtil::orderGuildChannels)
- Parameters:
channels
- The guild channels to sort.- Returns:
- The sorted guild channels.
-
orderRoles
Sortsroles
according to visual ordering in Discord. Roles at the bottom of the list are first. This sorts roles according toROLE_ORDER
.This function can be used with
Flux.transform(Function)
for better chaining:guild.getRoles() .transform(OrderUtil::orderRoles)
- Parameters:
roles
- The roles to sort.- Returns:
- The sorted roles.
-