Package net.dv8tion.jda.api.entities
Interface Emote
-
- All Superinterfaces:
Formattable
,IFakeable
,IMentionable
,ISnowflake
- All Known Subinterfaces:
ListedEmote
public interface Emote extends IMentionable, IFakeable
Represents a Custom Emote. (Custom Emoji in official Discord API terminology)You can retrieve the creator of an emote by using
Guild.retrieveEmote(Emote)
followed by usingListedEmote.getUser()
.This does not represent unicode emojis like they are used in the official client! (:smiley: is not a custom emoji)
Fake Emote
When an emote is declared as fake it cannot be updated by JDA. That means it will not be accessible through cache such asGuild.getEmoteCache()
and similar.
Fake emotes may or may not have an attachedGuild
and thus might not be manageable thoughgetManager()
ordelete()
. They also might lack attached roles forgetRoles()
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ICON_URL
Template forgetImageUrl()
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default boolean
canInteract(Member issuer)
Whether the specified Member can interact with this Emotedefault boolean
canInteract(User issuer, MessageChannel channel)
Whether the specified User can interact with this Emote within the provided MessageChannel
Same logic ascanInteract(issuer, channel, true)
!default boolean
canInteract(User issuer, MessageChannel channel, boolean botOverride)
Whether the specified User can interact with this Emote within the provided MessageChannel
Special override to exclude elevated bot permissions in case of (for instance) reacting to messages.boolean
canProvideRoles()
Whether this Emote has an attached roles list.AuditableRestAction<Void>
delete()
Deletes this Emote.default String
getAsMention()
Guild
getGuild()
TheGuild
this emote is attached to.default String
getImageUrl()
A String representation of the URL which leads to image displayed within the official Discord™ client when this Emote is usedJDA
getJDA()
TheJDA
instance of this EmoteEmoteManager
getManager()
TheManager
for this emote, used to modify properties of the emote like name and role restrictions.String
getName()
The name of this emote.List<Role>
getRoles()
Roles this emote is active for.default boolean
hasRoles()
Deprecated.This will be replaced bycanProvideRoles()
boolean
isAnimated()
Whether or not this Emote is animated.boolean
isManaged()
Whether this emote is managed.-
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Field Detail
-
ICON_URL
static final String ICON_URL
Template forgetImageUrl()
- See Also:
- Constant Field Values
-
-
Method Detail
-
getGuild
@Nullable Guild getGuild()
TheGuild
this emote is attached to.This is null if the emote is fake (retrieved from a Message)
- Returns:
- Guild of this emote or null if it is a fake entity
-
getRoles
@Nonnull List<Role> getRoles()
Roles this emote is active for.
Learn More- Returns:
- An immutable list of the roles this emote is active for (all roles if empty)
- Throws:
IllegalStateException
- If this Emote does not have attached roles according tocanProvideRoles()
- See Also:
canProvideRoles()
-
hasRoles
@Deprecated @DeprecatedSince("3.8.0") @ReplaceWith("canProvideRoles()") default boolean hasRoles()
Deprecated.This will be replaced bycanProvideRoles()
Whether this Emote has attached roles. This might not be the case when the emote is retrieved through special cases like audit-logs.If this is not true then
getRoles()
will throwIllegalStateException
.- Returns:
- True, if this emote has roles attached
-
canProvideRoles
boolean canProvideRoles()
Whether this Emote has an attached roles list. This might not be the case when the emote is retrieved through special cases like audit-logs.If this is not true then
getRoles()
will throwIllegalStateException
.- Returns:
- True, if this emote has an attached roles list
-
getName
@Nonnull String getName()
The name of this emote.
Does not include colons.- Returns:
- String representation of this emote's name
-
isManaged
boolean isManaged()
Whether this emote is managed. A managed Emote is controlled by Discord, not the Guild administrator, typical via a service like BTTV in conjunction with Twitch.
Learn More- Returns:
- True, if this emote is managed
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<Void> delete()
Deletes this Emote.Possible ErrorResponses include:
UNKNOWN_EMOTE
If this Emote was already removedUNKNOWN_GUILD
If the Guild of this Emote was deletedMISSING_ACCESS
If we were removed from the Guild
- Returns:
AuditableRestAction
The RestAction to delete this Emote.- Throws:
IllegalStateException
- if this Emote is fake (IFakeable.isFake()
)UnsupportedOperationException
- If this emote is managed by discord (isManaged()
)InsufficientPermissionException
- if the PermissionMANAGE_EMOTES
is not given
-
getManager
@Nonnull EmoteManager getManager()
TheManager
for this emote, used to modify properties of the emote like name and role restrictions.
You modify multiple fields in one request by chaining setters before callingRestAction.queue()
.- Returns:
- The EmoteManager for this Emote
- Throws:
IllegalStateException
- if this emote is fakeInsufficientPermissionException
- If the currently logged in account does not havePermission.MANAGE_EMOTES
-
isAnimated
boolean isAnimated()
Whether or not this Emote is animated.Animated Emotes are available to Discord Nitro users as well as Bot accounts.
- Returns:
- Whether the Emote is animated or not.
-
getImageUrl
@Nonnull default String getImageUrl()
A String representation of the URL which leads to image displayed within the official Discord™ client when this Emote is used- Returns:
- Discord CDN link to the Emote's image
-
getAsMention
@Nonnull default String getAsMention()
Usable representation of this Emote (used to display in the client just like mentions with a specific format)
Emotes are used with the format<:
getName()
:getId()
>- Specified by:
getAsMention
in interfaceIMentionable
- Returns:
- A usable String representation for this Emote
- See Also:
- Message Formatting
-
canInteract
default boolean canInteract(Member issuer)
Whether the specified Member can interact with this Emote- Parameters:
issuer
- The User to test- Returns:
- True, if the provided Member can use this Emote
-
canInteract
default boolean canInteract(User issuer, MessageChannel channel)
Whether the specified User can interact with this Emote within the provided MessageChannel
Same logic ascanInteract(issuer, channel, true)
!- Parameters:
issuer
- The User to testchannel
- The MessageChannel to test- Returns:
- True, if the provided Member can use this Emote
-
canInteract
default boolean canInteract(User issuer, MessageChannel channel, boolean botOverride)
Whether the specified User can interact with this Emote within the provided MessageChannel
Special override to exclude elevated bot permissions in case of (for instance) reacting to messages.- Parameters:
issuer
- The User to testchannel
- The MessageChannel to testbotOverride
- Whether bots can use non-managed emotes in other guilds- Returns:
- True, if the provided Member can use this Emote
-
-