Package discord4j.core.object.entity
Class GuildEmoji
- java.lang.Object
-
- discord4j.core.object.entity.GuildEmoji
-
- All Implemented Interfaces:
DiscordObject
,Entity
public final class GuildEmoji extends Object implements Entity
A Discord guild emoji.
-
-
Constructor Summary
Constructors Constructor Description GuildEmoji(GatewayDiscordClient gateway, discord4j.discordjson.json.EmojiData data, long guildId)
Constructs aGuildEmoji
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
asFormat()
Gets the formatted version of this emoji (i.e., to display in the client).Mono<Void>
delete()
Requests to delete this emoji.Mono<Void>
delete(String reason)
Requests to delete this emoji while optionally specifying a reason.discord4j.core.spec.GuildEmojiEditMono
edit()
Requests to edit this guild emoji.Mono<GuildEmoji>
edit(discord4j.core.spec.GuildEmojiEditSpec spec)
Requests to edit this guild emoji.Mono<GuildEmoji>
edit(Consumer<? super LegacyGuildEmojiEditSpec> spec)
Deprecated.useedit(GuildEmojiEditSpec)
oredit()
which offer an immutable approach to build specsboolean
equals(Object obj)
GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.discord4j.discordjson.json.EmojiData
getData()
Gets the data of the emoji.Mono<Guild>
getGuild()
Requests to retrieve the guild this emoji is associated to.Mono<Guild>
getGuild(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the guild this emoji is associated to, using the given retrieval strategy.Snowflake
getGuildId()
Gets the ID of the guild this emoji is associated to.Snowflake
getId()
Gets the Snowflake that uniquely identifies this entity.Mono<Image>
getImage()
Gets the image for this guild emoji.String
getImageUrl()
Gets the URL for this guild emoji.String
getName()
Gets the emoji name.Set<Snowflake>
getRoleIds()
Gets the IDs of the roles this emoji is whitelisted to.Flux<Role>
getRoles()
Requests to retrieve the roles this emoji is whitelisted to.Flux<Role>
getRoles(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the roles this emoji is whitelisted to, using the given retrieval strategy.Mono<User>
getUser()
Requests to retrieve the user that created this emoji.int
hashCode()
boolean
isAnimated()
Gets whether this emoji is animated.boolean
isAvailable()
Gets whether this emoji is available for use.boolean
isManaged()
Gets whether this emoji is managed.boolean
requiresColons()
Gets whether this emoji must be wrapped in colons.String
toString()
-
-
-
Constructor Detail
-
GuildEmoji
public GuildEmoji(GatewayDiscordClient gateway, discord4j.discordjson.json.EmojiData data, long guildId)
Constructs aGuildEmoji
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.guildId
- The ID of the guild this emoji is associated to.
-
-
Method Detail
-
getClient
public 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 Snowflake getId()
Description copied from interface:Entity
Gets the Snowflake that uniquely identifies this entity.
-
getData
public discord4j.discordjson.json.EmojiData getData()
Gets the data of the emoji.- Returns:
- The data of the emoji.
-
getName
public String getName()
Gets the emoji name.- Returns:
- The emoji name.
-
getRoleIds
public Set<Snowflake> getRoleIds()
Gets the IDs of the roles this emoji is whitelisted to.- Returns:
- The IDs of the roles this emoji is whitelisted to.
-
getRoles
public Flux<Role> getRoles()
Requests to retrieve the roles this emoji is whitelisted to.The order of items emitted by the returned
Flux
is unspecified. UseOrderUtil.orderRoles(Flux)
to consistently order roles.
-
getRoles
public Flux<Role> getRoles(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the roles this emoji is whitelisted to, using the given retrieval strategy.The order of items emitted by the returned
Flux
is unspecified. UseOrderUtil.orderRoles(Flux)
to consistently order roles.
-
getUser
public Mono<User> getUser()
Requests to retrieve the user that created this emoji. This method will always hit the REST API.
-
requiresColons
public boolean requiresColons()
Gets whether this emoji must be wrapped in colons.- Returns:
true
if this emoji must be wrapped in colons,false
otherwise.
-
isManaged
public boolean isManaged()
Gets whether this emoji is managed.- Returns:
true
if this emoji is managed,false
otherwise.
-
isAnimated
public boolean isAnimated()
Gets whether this emoji is animated.- Returns:
true
if this emoji is animated,false
otherwise.
-
isAvailable
public boolean isAvailable()
Gets whether this emoji is available for use.- Returns:
true
if this emoji is available,false
otherwise (due to loss of Server Boosts for example).
-
getGuildId
public Snowflake getGuildId()
Gets the ID of the guild this emoji is associated to.- Returns:
- The ID of the guild this emoji is associated to.
-
getGuild
public Mono<Guild> getGuild(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the guild this emoji is associated to, using the given retrieval strategy.
-
edit
@Deprecated public Mono<GuildEmoji> edit(Consumer<? super LegacyGuildEmojiEditSpec> spec)
Deprecated.useedit(GuildEmojiEditSpec)
oredit()
which offer an immutable approach to build specsRequests to edit this guild emoji.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyGuildEmojiEditSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits the editedGuildEmoji
. If an error is received, it is emitted through theMono
.
-
edit
public discord4j.core.spec.GuildEmojiEditMono edit()
Requests to edit this guild emoji. Properties specifying how to edit this emoji can be set via thewithXxx
methods of the returnedGuildEmojiEditMono
.- Returns:
- A
GuildEmojiEditMono
where, upon successful completion, emits the editedGuildEmoji
. If an error is received, it is emitted through theGuildEmojiEditMono
.
-
edit
public Mono<GuildEmoji> edit(discord4j.core.spec.GuildEmojiEditSpec spec)
Requests to edit this guild emoji.- Parameters:
spec
- an immutable object that specifies how to edit this emoji- Returns:
- A
Mono
where, upon successful completion, emits the editedGuildEmoji
. If an error is received, it is emitted through theMono
.
-
delete
public Mono<Void> delete()
Requests to delete this emoji.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the emoji has been deleted. If an error is received, it is emitted through theMono
.
-
delete
public Mono<Void> delete(@Nullable String reason)
Requests to delete this emoji while optionally specifying a reason.- Parameters:
reason
- The reason, if present.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the emoji has been deleted. If an error is received, it is emitted through theMono
.
-
getImageUrl
public String getImageUrl()
Gets the URL for this guild emoji.- Returns:
- The URL for this guild emoji.
-
asFormat
public String asFormat()
Gets the formatted version of this emoji (i.e., to display in the client).- Returns:
- The formatted version of this emoji (i.e., to display in the client).
-
-