Class Category
- java.lang.Object
-
- discord4j.core.object.entity.channel.Category
-
- All Implemented Interfaces:
DiscordObject
,Channel
,GuildChannel
,Entity
public final class Category extends Object
A Discord category.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface discord4j.core.object.entity.channel.Channel
Channel.Type
-
-
Constructor Summary
Constructors Constructor Description Category(GatewayDiscordClient gateway, discord4j.discordjson.json.ChannelData data)
Constructs anCategory
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Mono<Void>
addMemberOverwrite(Snowflake memberId, PermissionOverwrite overwrite, String reason)
Requests to add a permission overwrite for the given member while optionally specifying a reason.Mono<Void>
addRoleOverwrite(Snowflake roleId, PermissionOverwrite overwrite, String reason)
Requests to add a permission overwrite for the given role while optionally specifying a reason.Mono<Void>
delete(String reason)
Requests to delete this channel while optionally specifying a reason.discord4j.core.spec.CategoryEditMono
edit()
Requests to edit this category.Mono<Category>
edit(discord4j.core.spec.CategoryEditSpec spec)
Requests to edit this category.Mono<Category>
edit(Consumer<? super LegacyCategoryEditSpec> spec)
Deprecated.useedit(CategoryEditSpec)
oredit()
which offer an immutable approach to build specsboolean
equals(Object obj)
Flux<CategorizableChannel>
getChannels()
Requests to retrieve the channels residing in this category.Flux<CategorizableChannel>
getChannels(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the channels residing in this category, using the given retrieval strategy.GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.Mono<PermissionSet>
getEffectivePermissions(Snowflake memberId)
Gets the permissions for the given member, taking into account permission overwrites in this channel.Mono<PermissionSet>
getEffectivePermissions(Member member)
Gets the permissions for the given member, taking into account permission overwrites in this channel.Mono<Guild>
getGuild()
Requests to retrieve the guild this channel is associated to.Mono<Guild>
getGuild(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the guild this channel is associated to, using the given retrieval strategy.Snowflake
getGuildId()
Gets the ID of the guild this channel is associated to.Snowflake
getId()
Gets the Snowflake that uniquely identifies this entity.String
getName()
Gets the name of the channel.Optional<ExtendedPermissionOverwrite>
getOverwriteForMember(Snowflake memberId)
Gets the permission overwrite targeting the given member.Optional<ExtendedPermissionOverwrite>
getOverwriteForRole(Snowflake roleId)
Gets the permission overwrite targeting the given role.Set<ExtendedPermissionOverwrite>
getPermissionOverwrites()
Gets the permission overwrites for this channel.Mono<Integer>
getPosition()
Requests to retrieve the position of the channel relative to other channels in the guild.int
getRawPosition()
Gets the raw position of the channel as exposed by Discord.RestChannel
getRestChannel()
Return aRestChannel
handle to execute REST API operations on this entity.Channel.Type
getType()
Gets the type of channel.int
hashCode()
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface discord4j.core.object.entity.channel.Channel
delete, delete, getMention, getRestChannel, getType
-
Methods inherited from interface discord4j.core.object.DiscordObject
getClient
-
Methods inherited from interface discord4j.core.object.entity.channel.GuildChannel
addMemberOverwrite, addRoleOverwrite
-
-
-
-
Constructor Detail
-
Category
public Category(GatewayDiscordClient gateway, discord4j.discordjson.json.ChannelData data)
Constructs anCategory
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
associated to this object, must be non-null.data
- The raw data as represented by Discord, must be non-null.
-
-
Method Detail
-
getChannels
public Flux<CategorizableChannel> getChannels()
Requests to retrieve the channels residing in this category.
-
getChannels
public Flux<CategorizableChannel> getChannels(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the channels residing in this category, using the given retrieval strategy.
-
edit
@Deprecated public Mono<Category> edit(Consumer<? super LegacyCategoryEditSpec> spec)
Deprecated.useedit(CategoryEditSpec)
oredit()
which offer an immutable approach to build specsRequests to edit this category.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyCategoryEditSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits the editedCategory
. If an error is received, it is emitted through theMono
.
-
edit
public discord4j.core.spec.CategoryEditMono edit()
Requests to edit this category. Properties specifying how to edit this category can be set via thewithXxx
methods of the returnedCategoryEditMono
.- Returns:
- A
CategoryEditMono
where, upon successful completion, emits the editedCategory
. If an error is received, it is emitted through theCategoryEditMono
.
-
edit
public Mono<Category> edit(discord4j.core.spec.CategoryEditSpec spec)
Requests to edit this category.
-
toString
public String toString()
-
getGuildId
public final Snowflake getGuildId()
Description copied from interface:GuildChannel
Gets the ID of the guild this channel is associated to.- Specified by:
getGuildId
in interfaceGuildChannel
- Returns:
- The ID of the guild this channel is associated to.
-
getGuild
public final Mono<Guild> getGuild()
Description copied from interface:GuildChannel
Requests to retrieve the guild this channel is associated to.- Specified by:
getGuild
in interfaceGuildChannel
- Returns:
- A
Mono
where, upon successful completion, emits theguild
this channel is associated to. If an error is received, it is emitted through theMono
.
-
getGuild
public Mono<Guild> getGuild(EntityRetrievalStrategy retrievalStrategy)
Description copied from interface:GuildChannel
Requests to retrieve the guild this channel is associated to, using the given retrieval strategy.- Specified by:
getGuild
in interfaceGuildChannel
- Parameters:
retrievalStrategy
- the strategy to use to get the guild- Returns:
- A
Mono
where, upon successful completion, emits theguild
this channel is associated to. If an error is received, it is emitted through theMono
.
-
getPermissionOverwrites
public final Set<ExtendedPermissionOverwrite> getPermissionOverwrites()
Description copied from interface:GuildChannel
Gets the permission overwrites for this channel.- Specified by:
getPermissionOverwrites
in interfaceGuildChannel
- Returns:
- The permission overwrites for this channel.
-
getOverwriteForMember
public Optional<ExtendedPermissionOverwrite> getOverwriteForMember(Snowflake memberId)
Description copied from interface:GuildChannel
Gets the permission overwrite targeting the given member.- Specified by:
getOverwriteForMember
in interfaceGuildChannel
- Parameters:
memberId
- The ID of the member to get the overwrite for.- Returns:
- The permission overwrite targeting the given member.
-
getOverwriteForRole
public Optional<ExtendedPermissionOverwrite> getOverwriteForRole(Snowflake roleId)
Description copied from interface:GuildChannel
Gets the permission overwrite targeting the given role.- Specified by:
getOverwriteForRole
in interfaceGuildChannel
- Parameters:
roleId
- The ID of the role to get the overwrite for.- Returns:
- The permission overwrite targeting the given role.
-
getEffectivePermissions
public Mono<PermissionSet> getEffectivePermissions(Snowflake memberId)
Description copied from interface:GuildChannel
Gets the permissions for the given member, taking into account permission overwrites in this channel.- Specified by:
getEffectivePermissions
in interfaceGuildChannel
- Parameters:
memberId
- The ID of the member to get permissions for.- Returns:
- The permissions for the given member.
-
getEffectivePermissions
public Mono<PermissionSet> getEffectivePermissions(Member member)
Description copied from interface:GuildChannel
Gets the permissions for the given member, taking into account permission overwrites in this channel.- Specified by:
getEffectivePermissions
in interfaceGuildChannel
- Parameters:
member
- The member to get permissions for.- Returns:
- The permissions for the given member.
-
getName
public final String getName()
Description copied from interface:GuildChannel
Gets the name of the channel.- Specified by:
getName
in interfaceGuildChannel
- Returns:
- The name of the channel.
-
getRawPosition
public int getRawPosition()
Description copied from interface:GuildChannel
Gets the raw position of the channel as exposed by Discord. This may or may not be accurate with relativity to other channels in the guild.- Specified by:
getRawPosition
in interfaceGuildChannel
- Returns:
- The raw position of the channel.
-
getPosition
public final Mono<Integer> getPosition()
Description copied from interface:GuildChannel
Requests to retrieve the position of the channel relative to other channels in the guild.This is determined by the index of this channel in the
sorted
list of channels of the guild.Warning: Because this method must sort the guild channels, it is inefficient to make repeated invocations for the same set of channels (meaning that channels haven't been added or removed). For example, instead of writing:
guild.getChannels() .flatMap(c -> c.getPosition().map(pos -> c.getName() + " : " + pos))
guild.getChannels() .transform(OrderUtil::orderGuildChannels) .index((pos, c) -> c.getName() + " : " + pos)
- Specified by:
getPosition
in interfaceGuildChannel
- Returns:
- A
Mono
where, upon successful completion, emits the position of the channel. If an error is received, it is emitted through theMono
.
-
addMemberOverwrite
public Mono<Void> addMemberOverwrite(Snowflake memberId, PermissionOverwrite overwrite, @Nullable String reason)
Description copied from interface:GuildChannel
Requests to add a permission overwrite for the given member while optionally specifying a reason.- Specified by:
addMemberOverwrite
in interfaceGuildChannel
- Parameters:
memberId
- The ID of the member to add the overwrite for.overwrite
- The overwrite to add.reason
- The reason, if present.- Returns:
- A
Mono
where, upon successful completion, emits nothing; If an error is received, it is emitted through theMono
.
-
addRoleOverwrite
public Mono<Void> addRoleOverwrite(Snowflake roleId, PermissionOverwrite overwrite, @Nullable String reason)
Description copied from interface:GuildChannel
Requests to add a permission overwrite for the given role while optionally specifying a reason.- Specified by:
addRoleOverwrite
in interfaceGuildChannel
- Parameters:
roleId
- The ID of the role to add the overwrite for.overwrite
- The overwrite to add.reason
- The reason, if present.- Returns:
- A
Mono
where, upon successful completion, emits nothing; If an error is received, it is emitted through theMono
.
-
getClient
public final GatewayDiscordClient getClient()
Description copied from interface:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-
getId
public final Snowflake getId()
Description copied from interface:Entity
Gets the Snowflake that uniquely identifies this entity.
-
getRestChannel
public RestChannel getRestChannel()
Description copied from interface:Channel
Return aRestChannel
handle to execute REST API operations on this entity.- Specified by:
getRestChannel
in interfaceChannel
-
getType
public final Channel.Type getType()
Description copied from interface:Channel
Gets the type of channel.
-
delete
public final Mono<Void> delete(@Nullable String reason)
Description copied from interface:Channel
Requests to delete this channel while optionally specifying a reason.
-
-