Interface Message
-
- All Superinterfaces:
Formattable,ISnowflake
public interface Message extends ISnowflake, Formattable
Represents a Text message received from Discord.
This represents messages received fromMessageChannels.This type is not updated. JDA does not keep track of changes to messages, it is advised to do this via events such as
MessageUpdateEventand similar.Message Differences
There are 3 implementations of this interface in JDA.- Received Message
Messages received through events or history query. These messages hold information of existing messages and can be modified or deleted. - System Message
Specification of Received Messages that are generated by Discord on certain events. Commonly this is used in groups or to indicate a pin within a MessageChannel. The different types can be found in theMessageTypeenum. - Data Message
This type is produced byMessageBuilderand only holds sendable information such as content or nonce. These messages do not allow any modifications via RestActions or information that is generated when sent such as the id to be used.
When a feature is not available it will throw an
UnsupportedOperationExceptionas per interface specifications.
Specific operations may have specified information available in thethrowsjavadoc.Formattable
This interface extendsFormattableand can be used with aFormattersuch as used byString.format(String, Object...)orPrintStream.printf(String, Object...).This will use
getContentDisplay()rather thanObject.toString()!
Supported Features:- Alternative
- UsinggetContentRaw()(Example:%#s- usesgetContentDisplay()) - Width/Left-Justification
- Ensures the size of a format (Example:%20s- uses at minimum 20 chars;%-10s- uses left-justified padding) - Precision
- Cuts the content to the specified size (replacing last 3 chars with...; Example:%.20s)
More information on formatting syntax can be found in the
format syntax documentation!- See Also:
MessageBuilder,MessageChannel.sendMessage(Message),MessageChannel.getIterableHistory(),MessageChannel.getHistory(),MessageChannel.getHistoryAfter(String, int),MessageChannel.getHistoryBefore(String, int),MessageChannel.getHistoryAround(String, int),MessageChannel.getHistoryFromBeginning(int),MessageChannel.retrieveMessageById(String),MessageChannel.deleteMessageById(String),MessageChannel.editMessageById(String, CharSequence)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMessage.AttachmentRepresents aMessagefile attachment.static classMessage.MentionTypeMention formatting constants, useful for use withPatternsstatic classMessage.MessageFlagEnum representing the flags on a Message.
-
Field Summary
Fields Modifier and Type Field Description static PatternINVITE_PATTERNPattern used to find instant invites in strings.static PatternJUMP_URL_PATTERNPattern used to findJump URLsin strings.static intMAX_CONTENT_LENGTHThe maximum amount of characters sendable in one message.static intMAX_FILE_AMOUNTThe maximum amount of files sendable within a single message (10)static intMAX_FILE_SIZEThe maximum sendable file size (8 MiB)static intMAX_FILE_SIZE_NITROThe maximum sendable file size for nitro (50 MiB)
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RestAction<Void>addReaction(String unicode)Adds a reaction to this Message using a unicode emoji.RestAction<Void>addReaction(Emote emote)Adds a reaction to this Message using anEmote.RestAction<Void>clearReactions()Removes all reactions from this Message.RestAction<Void>clearReactions(String unicode)Removes all reactions for the specified emoji.RestAction<Void>clearReactions(Emote emote)Removes all reactions for the specified emote.AuditableRestAction<Void>delete()Deletes this Message from Discord.MessageActioneditMessage(CharSequence newContent)Edits this Message's content to the provided String.MessageActioneditMessage(Message newContent)Edits this Message's content to the providedMessage.MessageActioneditMessage(MessageEmbed newContent)Edits this Message's content to the providedMessageEmbed.MessageActioneditMessageFormat(String format, Object... args)Edits this Message's content to the provided format.MessageActivitygetActivity()AMessageActivitythat contains its type and party id.List<Message.Attachment>getAttachments()An immutable list ofAttachmentsthat are attached to this message.UsergetAuthor()The author of this MessageCategorygetCategory()TheCategorythis message was sent in.MessageChannelgetChannel()Returns theMessageChannelthat this message was sent in.ChannelTypegetChannelType()Gets theChannelTypethat this message was received from.StringgetContentDisplay()The textual content of this message in the format that would be shown to the Discord client.StringgetContentRaw()The raw textual content of this message.StringgetContentStripped()Gets the textual content of this message usinggetContentDisplay()and then strips it of markdown characters like *, **, __, ~~, || that provide text formatting.List<MessageEmbed>getEmbeds()An immutable list ofMessageEmbedsthat are part of this Message.List<Emote>getEmotes()AllEmotesused in this Message.org.apache.commons.collections4.Bag<Emote>getEmotesBag()ABagof emotes used in this message.EnumSet<Message.MessageFlag>getFlags()Returns an EnumSet of allMessageFlagspresent for this Message.GuildgetGuild()Returns theGuildthat this message was sent in.List<String>getInvites()Creates an immutable List ofInvitecodes that are included in this Message.JDAgetJDA()Returns theJDAinstance related to this Message.StringgetJumpUrl()Returns the jump-to URL for the received message.MembergetMember()Returns the author of this Message as amember.List<TextChannel>getMentionedChannels()A immutable list of all mentionedTextChannels.org.apache.commons.collections4.Bag<TextChannel>getMentionedChannelsBag()ABagof mentioned channels.List<Member>getMentionedMembers()Creates an immutable list ofMembersrepresenting the users ofgetMentionedUsers()in theGuildthis Message was sent in.List<Member>getMentionedMembers(Guild guild)Creates an immutable list ofMembersrepresenting the users ofgetMentionedUsers()in the specifiedGuild.List<Role>getMentionedRoles()A immutable list of all mentionedRoles.org.apache.commons.collections4.Bag<Role>getMentionedRolesBag()ABagof mentioned roles.List<User>getMentionedUsers()An immutable list of all mentionedUsers.org.apache.commons.collections4.Bag<User>getMentionedUsersBag()ABagof mentioned users.List<IMentionable>getMentions(Message.MentionType... types)Combines all instances ofIMentionablefiltered by the specifiedMentionTypevalues.StringgetNonce()Validation nonce for this Message
This can be used to validate that a Message was properly sent to the Discord Service.PrivateChannelgetPrivateChannel()Returns thePrivateChannelthat this message was sent in.MessageReaction.ReactionEmotegetReactionById(long id)This obtains theReactionEmotefor the given reaction id on this message.MessageReaction.ReactionEmotegetReactionById(String id)This obtains theReactionEmotefor the given reaction id on this message.MessageReaction.ReactionEmotegetReactionByUnicode(String unicode)This obtains theReactionEmotefor the given unicode reaction on this message.List<MessageReaction>getReactions()AllMessageReactionsthat are on this Message.TextChannelgetTextChannel()Returns theTextChannelthat this message was sent in.OffsetDateTimegetTimeEdited()Provides theOffsetDateTimedefining when this Message was last edited.MessageTypegetType()This specifies theMessageTypeof this Message.booleanisEdited()Returns whether or not this Message has been edited before.default booleanisFromGuild()Whether this message was sent in aGuild.booleanisFromType(ChannelType type)Used to determine if this Message was received from aMessageChannelof theChannelTypespecified.booleanisMentioned(IMentionable mentionable, Message.MentionType... types)Checks if givenIMentionablewas mentioned in this message in any way (@User, @everyone, @here, @Role).booleanisPinned()Whether or not this Message has been pinned in its parent channel.booleanisSuppressedEmbeds()Whether embeds are suppressed for this message.booleanisTTS()Defines whether or not this Message triggers TTS (Text-To-Speech).booleanisWebhookMessage()booleanmentionsEveryone()Indicates if this Message mentions everyone using @everyone or @here.RestAction<Void>pin()Used to add the Message to theMessageChannel'spinned message list.RestAction<Void>removeReaction(String unicode)Removes a reaction from this Message using a unicode emoji.RestAction<Void>removeReaction(String unicode, User user)Removes a reaction from this Message using a unicode emoji.RestAction<Void>removeReaction(Emote emote)Removes a reaction from this Message using anEmote.RestAction<Void>removeReaction(Emote emote, User user)ReactionPaginationActionretrieveReactionUsers(String unicode)This obtains theuserswho reacted using the given unicode emoji.ReactionPaginationActionretrieveReactionUsers(Emote emote)AuditableRestAction<Void>suppressEmbeds(boolean suppressed)Enables/Disables suppression of Embeds on this Message.RestAction<Void>unpin()Used to remove the Message from theMessageChannel'spinned message list.-
Methods inherited from interface java.util.Formattable
formatTo
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
-
-
-
-
Field Detail
-
MAX_FILE_SIZE
static final int MAX_FILE_SIZE
The maximum sendable file size (8 MiB)- See Also:
MessageAction.addFile(...), Constant Field Values
-
MAX_FILE_SIZE_NITRO
static final int MAX_FILE_SIZE_NITRO
The maximum sendable file size for nitro (50 MiB)- See Also:
MessageAction.addFile(...), Constant Field Values
-
MAX_FILE_AMOUNT
static final int MAX_FILE_AMOUNT
The maximum amount of files sendable within a single message (10)- See Also:
MessageAction.addFile(...), Constant Field Values
-
MAX_CONTENT_LENGTH
static final int MAX_CONTENT_LENGTH
The maximum amount of characters sendable in one message. (2000)
This only applies to the raw content and not embeds!- See Also:
MessageAction.append(...), Constant Field Values
-
INVITE_PATTERN
static final Pattern INVITE_PATTERN
Pattern used to find instant invites in strings.The only named group is at index 1 with the name
"code".- See Also:
getInvites()
-
JUMP_URL_PATTERN
static final Pattern JUMP_URL_PATTERN
Pattern used to findJump URLsin strings.Groups
You can use the names withIndex Name Description 0 N/A The entire link 1 guild The ID of the target guild 2 channel The ID of the target channel 3 message The ID of the target message Matcher.group(String)and the index withMatcher.group(int).- See Also:
getJumpUrl()
-
-
Method Detail
-
getMentionedUsers
@Nonnull List<User> getMentionedUsers()
An immutable list of all mentionedUsers.
If no user was mentioned, this list is empty. Elements are sorted in order of appearance. This only counts direct mentions of the user and not mentions through roles or the everyone tag.- Returns:
- immutable list of mentioned users
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getMentionedUsersBag
@Nonnull org.apache.commons.collections4.Bag<User> getMentionedUsersBag()
ABagof mentioned users.
This can be used to retrieve the amount of times a user was mentioned in this message. This only counts direct mentions of the user and not mentions through roles or the everyone tag.Example
public void sendCount(Message msg) { List<User> mentions = msg.getMentionedUsers(); // distinct list, in order of appearance Bag<User> count = msg.getMentionedUsersBag(); StringBuilder content = new StringBuilder(); for (User user : mentions) { content.append(user.getAsTag()) .append(": ") .append(count.getCount(user)) .append("\n"); } msg.getChannel().sendMessage(content.toString()).queue(); }- Returns:
Bagof mentioned users- See Also:
getMentionedUsers()
-
getMentionedChannels
@Nonnull List<TextChannel> getMentionedChannels()
A immutable list of all mentionedTextChannels.
If none were mentioned, this list is empty. Elements are sorted in order of appearance.This may include TextChannels from other
Guilds- Returns:
- immutable list of mentioned TextChannels
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getMentionedChannelsBag
@Nonnull org.apache.commons.collections4.Bag<TextChannel> getMentionedChannelsBag()
ABagof mentioned channels.
This can be used to retrieve the amount of times a channel was mentioned in this message.Example
public void sendCount(Message msg) { List<TextChannel> mentions = msg.getMentionedTextChannels(); // distinct list, in order of appearance Bag<TextChannel> count = msg.getMentionedTextChannelsBag(); StringBuilder content = new StringBuilder(); for (TextChannel channel : mentions) { content.append("#") .append(channel.getName()) .append(": ") .append(count.getCount(channel)) .append("\n"); } msg.getChannel().sendMessage(content.toString()).queue(); }- Returns:
Bagof mentioned channels- See Also:
getMentionedChannels()
-
getMentionedRoles
@Nonnull List<Role> getMentionedRoles()
A immutable list of all mentionedRoles.
If none were mentioned, this list is empty. Elements are sorted in order of appearance. This only counts direct mentions of the role and not mentions through the everyone tag.This may include Roles from other
Guilds- Returns:
- immutable list of mentioned Roles
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getMentionedRolesBag
@Nonnull org.apache.commons.collections4.Bag<Role> getMentionedRolesBag()
ABagof mentioned roles.
This can be used to retrieve the amount of times a role was mentioned in this message. This only counts direct mentions of the role and not mentions through the everyone tag. If a role is notmentionableit will not be included.Example
public void sendCount(Message msg) { List<Role> mentions = msg.getMentionedRoles(); // distinct list, in order of appearance Bag<Role> count = msg.getMentionedRolesBag(); StringBuilder content = new StringBuilder(); for (Role role : mentions) { content.append(role.getName()) .append(": ") .append(count.getCount(role)) .append("\n"); } msg.getChannel().sendMessage(content.toString()).queue(); }- Returns:
Bagof mentioned roles- See Also:
getMentionedRoles()
-
getMentionedMembers
@Nonnull List<Member> getMentionedMembers(@Nonnull Guild guild)
Creates an immutable list ofMembersrepresenting the users ofgetMentionedUsers()in the specifiedGuild.
This is only a convenience method and will skip all users that are not in the specified Guild.- Parameters:
guild- Non-nullGuildthat will be used to retrieve Members.- Returns:
- Immutable list of mentioned Members
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalArgumentException- If the specified Guild isnull- Since:
- 3.4.0
-
getMentionedMembers
@Nonnull List<Member> getMentionedMembers()
Creates an immutable list ofMembersrepresenting the users ofgetMentionedUsers()in theGuildthis Message was sent in.
This is only a convenience method and will skip all users that are not in the specified Guild.
It will provide thegetGuild()output Guild togetMentionedMembers(Guild).- Returns:
- Immutable list of mentioned Members
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException- If this message was not sent in aTextChannel- Since:
- 3.4.0
-
getMentions
@Nonnull List<IMentionable> getMentions(@Nonnull Message.MentionType... types)
Combines all instances ofIMentionablefiltered by the specifiedMentionTypevalues.
This does not includegetMentionedMembers()to avoid duplicates.If no MentionType values are given this will fallback to all types.
- Parameters:
types- Amount ofMentionTypesto include in the list of mentions- Returns:
- Immutable list of filtered
IMentionableinstances - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalArgumentException- If provided withnull- Since:
- 3.4.0
-
isMentioned
boolean isMentioned(@Nonnull IMentionable mentionable, @Nonnull Message.MentionType... types)
Checks if givenIMentionablewas mentioned in this message in any way (@User, @everyone, @here, @Role).
If no filteringMentionTypesare specified this will fallback to all mention types.MentionType.HEREandMentionType.EVERYONEwill only be checked, if the givenIMentionableis of typeUserorMember.
Online status of Users/Members is NOT considered when checkingMentionType.HERE.- Parameters:
mentionable- The mentionable entity to check on.types- The types to include when checking whether this type was mentioned. This will be used withgetMentions(MentionType...)- Returns:
- True, if the given mentionable was mentioned in this message
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
mentionsEveryone
boolean mentionsEveryone()
Indicates if this Message mentions everyone using @everyone or @here.- Returns:
- True, if message is mentioning everyone
-
isEdited
boolean isEdited()
Returns whether or not this Message has been edited before.- Returns:
- True if this message has been edited.
-
getTimeEdited
@Nullable OffsetDateTime getTimeEdited()
Provides theOffsetDateTimedefining when this Message was last edited. If this Message has not been edited (isEdited()isfalse), then this method will returnnull.- Returns:
- Time of the most recent edit, or
nullif the Message has never been edited.
-
getAuthor
@Nonnull User getAuthor()
The author of this Message- Returns:
- Message author
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getMember
@Nullable Member getMember()
Returns the author of this Message as amember.
This is just a shortcut togetGuild().getMember(getAuthor()).
This is only valid if the Message was actually sent in a TextChannel. This will returnnullif the message was not sent in a TextChannel, or if the message was sent by a Webhook.
You can check the type of channel this message was sent from usingisFromType(ChannelType)orgetChannelType().- Returns:
- Message author, or
nullif the message was not sent in a TextChannel, or if the message was sent by a Webhook. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT- See Also:
isWebhookMessage()
-
getJumpUrl
@Nonnull String getJumpUrl()
Returns the jump-to URL for the received message. Clicking this URL in the Discord client will cause the client to jump to the specified message.- Returns:
- A String representing the jump-to URL for the message
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getContentDisplay
@Nonnull String getContentDisplay()
The textual content of this message in the format that would be shown to the Discord client. AllIMentionableentities will be resolved to the format shown by the Discord client instead of the <id> format.This includes resolving:
Users/Membersto their @Username/@Nickname format,TextChannelsto their #ChannelName format,Rolesto their @RoleName formatEmotes(not emojis!) to their:name:format.If you want the actual Content (mentions as <@id>), use
getContentRaw()instead- Returns:
- The textual content of the message with mentions resolved to be visually like the Discord client.
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getContentRaw
@Nonnull String getContentRaw()
The raw textual content of this message. Does not resolveIMentionableentities likegetContentDisplay()does. This means that this is the completely raw textual content of the message received from Discord and can contain mentions specified by Discord's Message Formatting.- Returns:
- The raw textual content of the message, containing unresolved Discord message formatting.
-
getContentStripped
@Nonnull String getContentStripped()
Gets the textual content of this message usinggetContentDisplay()and then strips it of markdown characters like *, **, __, ~~, || that provide text formatting. Any characters that match these but are not being used for formatting are escaped to prevent possible formatting.- Returns:
- The textual content from
getContentDisplay()with all text formatting characters removed or escaped.
-
getInvites
@Nonnull List<String> getInvites()
Creates an immutable List ofInvitecodes that are included in this Message.
This will use thePatternprovided underINVITE_PATTERNto construct aMatcherthat will parse thegetContentRaw()output and include all codes it finds in a list.You can use the codes to retrieve/validate invites via
Invite.resolve(JDA, String)- Returns:
- Immutable list of invite codes
-
getNonce
@Nullable String getNonce()
Validation nonce for this Message
This can be used to validate that a Message was properly sent to the Discord Service.
To set a nonce before sending you may useMessageBuilder.setNonce(String)!- Returns:
- The validation nonce
- Since:
- 3.4.0
- See Also:
MessageBuilder.setNonce(String), Cryptographic Nonce - Wikipedia
-
isFromType
boolean isFromType(@Nonnull ChannelType type)
Used to determine if this Message was received from aMessageChannelof theChannelTypespecified.
This will always be false forChannelType.VOICEas Messages can't be sent toVoiceChannels.Useful for restricting functionality to a certain type of channels.
- Parameters:
type- TheChannelTypeto check against.- Returns:
- True if the
ChannelTypewhich this message was received from is the same as the one specified bytype. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
isFromGuild
default boolean isFromGuild()
Whether this message was sent in aGuild.
If this isfalsethengetGuild()will throw anIllegalStateException.- Returns:
- True, if
getChannelType().isGuild()is true.
-
getChannelType
@Nonnull ChannelType getChannelType()
Gets theChannelTypethat this message was received from.
This will never beChannelType.VOICEas Messages can't be sent toVoiceChannels.- Returns:
- The ChannelType which this message was received from.
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
isWebhookMessage
boolean isWebhookMessage()
Indicates if this Message was sent by aWebhookinstead of aUser.
Useful if you want to ignore non-users.- Returns:
- True if this message was sent by a
Webhook.
-
getChannel
@Nonnull MessageChannel getChannel()
Returns theMessageChannelthat this message was sent in.- Returns:
- The MessageChannel of this Message
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getPrivateChannel
@Nonnull PrivateChannel getPrivateChannel()
Returns thePrivateChannelthat this message was sent in.
This is only valid if the Message was actually sent in a PrivateChannel.
You can check the type of channel this message was sent from usingisFromType(ChannelType)orgetChannelType().Use
getChannel()for an ambiguousMessageChannelif you do not need functionality specific toPrivateChannel.- Returns:
- The PrivateChannel this message was sent in
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException- If this was not sent in aPrivateChannel.- See Also:
isFromGuild(),isFromType(ChannelType),getChannelType()
-
getTextChannel
@Nonnull TextChannel getTextChannel()
Returns theTextChannelthat this message was sent in.
This is only valid if the Message was actually sent in a TextChannel.
You can check the type of channel this message was sent from usingisFromType(ChannelType)orgetChannelType().Use
getChannel()for an ambiguousMessageChannelif you do not need functionality specific toTextChannel.- Returns:
- The TextChannel this message was sent in
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException- If this was not sent in aTextChannel.- See Also:
isFromGuild(),isFromType(ChannelType),getChannelType()
-
getCategory
@Nullable Category getCategory()
TheCategorythis message was sent in. This will always benullfor DMs.
Equivalent togetTextChannel().getParent()if this was sent in aTextChannel.- Returns:
Categoryfor this message- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getGuild
@Nonnull Guild getGuild()
Returns theGuildthat this message was sent in.
This is just a shortcut togetTextChannel().getGuild().
This is only valid if the Message was actually sent in a TextChannel.
You can check the type of channel this message was sent from usingisFromType(ChannelType)orgetChannelType().- Returns:
- The Guild this message was sent in
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException- If this was not sent in aTextChannel.- See Also:
isFromGuild(),isFromType(ChannelType),getChannelType()
-
getAttachments
@Nonnull List<Message.Attachment> getAttachments()
An immutable list ofAttachmentsthat are attached to this message.
Most likely this will only ever be 1Attachmentat most.- Returns:
- Immutable list of
Attachments.
-
getEmbeds
@Nonnull List<MessageEmbed> getEmbeds()
An immutable list ofMessageEmbedsthat are part of this Message.- Returns:
- Immutable list of all given MessageEmbeds.
-
getEmotes
@Nonnull List<Emote> getEmotes()
AllEmotesused in this Message.
This only includes Custom Emotes, not unicode Emojis. JDA classifies Emotes as the Custom Emojis uploaded to a Guild and retrievable withGuild.getEmotes(). These are not the same as the unicode emojis that Discord also supports. Elements are sorted in order of appearance.This may or may not contain fake Emotes which means they can be displayed but not used by the logged in account. To check whether an Emote is fake you can test if
IFakeable.isFake()returns true.Unicode emojis are not included as
Emote!- Returns:
- An immutable list of the Emotes used in this message (example match <:jda:230988580904763393>)
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
getEmotesBag
@Nonnull org.apache.commons.collections4.Bag<Emote> getEmotesBag()
ABagof emotes used in this message.
This can be used to retrieve the amount of times an emote was used in this message.Example
public void sendCount(Message msg) { List<Emote> emotes = msg.getEmotes(); // distinct list, in order of appearance Bag<Emote> count = msg.getEmotesBag(); StringBuilder content = new StringBuilder(); for (Emote emote : emotes) { content.append(emote.getName()) .append(": ") .append(count.getCount(role)) .append("\n"); } msg.getChannel().sendMessage(content.toString()).queue(); }- Returns:
Bagof used emotes- See Also:
getEmotes()
-
getReactions
@Nonnull List<MessageReaction> getReactions()
AllMessageReactionsthat are on this Message.- Returns:
- Immutable list of all MessageReactions on this message.
-
isTTS
boolean isTTS()
Defines whether or not this Message triggers TTS (Text-To-Speech).- Returns:
- If this message is TTS.
-
getActivity
@Nullable MessageActivity getActivity()
AMessageActivitythat contains its type and party id.- Returns:
- The activity, or
nullif no activity was added to the message.
-
editMessage
@Nonnull @CheckReturnValue MessageAction editMessage(@Nonnull CharSequence newContent)
Edits this Message's content to the provided String.
Messages can only be edited by the account that sent them!.This message instance will not be updated by this operation, please use the response message instead.
The following
ErrorResponsesare possible:MISSING_ACCESS
The edit was attempted after the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The edit was attempted after the account lostPermission.MESSAGE_WRITEin theTextChannel.UNKNOWN_MESSAGE
The edit was attempted after the Message had been deleted.
- Parameters:
newContent- the new content of the Message- Returns:
MessageAction
TheMessagewith the updated content- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException- If the message attempting to be edited was not created by the currently logged in account, or ifnewContent's length is 0 or greater than 2000.
-
editMessage
@Nonnull @CheckReturnValue MessageAction editMessage(@Nonnull MessageEmbed newContent)
Edits this Message's content to the providedMessageEmbed.
Messages can only be edited by the account that sent them!.This message instance will not be updated by this operation, please use the response message instead.
The following
ErrorResponsesare possible:MISSING_ACCESS
The edit was attempted after the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The edit was attempted after the account lostPermission.MESSAGE_WRITEin theTextChannel.UNKNOWN_MESSAGE
The edit was attempted after the Message had been deleted.
- Parameters:
newContent- the new content of the Message- Returns:
MessageAction
TheMessagewith the updated content- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException- If the message attempting to be edited was not created by the currently logged in account, or if the passed-in embed isnullor notsendable
-
editMessageFormat
@Nonnull @CheckReturnValue MessageAction editMessageFormat(@Nonnull String format, @Nonnull Object... args)
Edits this Message's content to the provided format.
Shortcut forMessageBuilder.appendFormat(String, Object...).
Messages can only be edited by the account that sent them!.This message instance will not be updated by this operation, please use the response message instead.
The following
ErrorResponsesare possible:MISSING_ACCESS
The edit was attempted after the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The edit was attempted after the account lostPermission.MESSAGE_WRITEin theTextChannel.UNKNOWN_MESSAGE
The edit was attempted after the Message had been deleted.
- Parameters:
format- Format String used to generate the Message's content viaMessageBuilder.appendFormat(String, Object...)specificationargs- The arguments to use in order to be converted in the format string- Returns:
MessageAction
TheMessagewith the updated content- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalArgumentException- If the provided format String isnullor blank, or if the created message exceeds the 2000 character limitIllegalFormatException- If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.IllegalStateException- If the message attempting to be edited was not created by the currently logged in account
-
editMessage
@Nonnull @CheckReturnValue MessageAction editMessage(@Nonnull Message newContent)
Edits this Message's content to the providedMessage.
Messages can only be edited by the account that sent them!.This message instance will not be updated by this operation, please use the response message instead.
The following
ErrorResponsesare possible:MISSING_ACCESS
The edit was attempted after the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The edit was attempted after the account lostPermission.MESSAGE_WRITEin theTextChannel.UNKNOWN_MESSAGE
The edit was attempted after the Message had been deleted.
- Parameters:
newContent- the new content of the Message- Returns:
MessageAction
TheMessagewith the updated content- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalStateException-- If the message attempting to be edited was not created by the currently logged in account
- If the message contains a MessageEmbed that is not
sendable
-
delete
@Nonnull @CheckReturnValue AuditableRestAction<Void> delete()
Deletes this Message from Discord.
If this Message was not sent by the currently logged in account, then this will fail unless the Message is from aTextChanneland the current account hasPermission.MESSAGE_MANAGEin the channel.To delete many messages at once in a
MessageChannelyou should useMessageChannel.purgeMessages(List)instead.The following
ErrorResponsesare possible:MISSING_ACCESS
The delete was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The delete was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen deleting another Member's message or lostPermission.MESSAGE_MANAGE.UNKNOWN_MESSAGEThe message was already deleted at the time the request was sent.
- Returns:
AuditableRestAction- Throws:
UnsupportedOperationException- If this is a Data Message (output ofMessageBuilder)InsufficientPermissionException- If this Message was not sent by the currently logged in account, the Message was sent in aTextChannel, and the currently logged in account does not havePermission.MESSAGE_MANAGEin the channel.IllegalStateException- If this Message was not sent by the currently logged in account and it was not sent in aTextChannel.- See Also:
TextChannel.deleteMessages(Collection),MessageChannel.purgeMessages(List)
-
getJDA
@Nonnull JDA getJDA()
Returns theJDAinstance related to this Message.- Returns:
- the corresponding JDA instance
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT
-
isPinned
boolean isPinned()
Whether or not this Message has been pinned in its parent channel.- Returns:
- True - if this message has been pinned.
-
pin
@Nonnull @CheckReturnValue RestAction<Void> pin()
Used to add the Message to theMessageChannel'spinned message list.
This is a shortcut method toMessageChannel.pinMessageById(String).The success or failure of this action will not affect the return of
isPinned().The following
ErrorResponsesare possible:MISSING_ACCESS
The pin request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The pin request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannel.UNKNOWN_MESSAGEThe pin request was attempted after the Message had been deleted.
- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If this Message is from aTextChanneland:- Missing
Permission.MESSAGE_READ.
The account needs access the the channel to pin a message in it. - Missing
Permission.MESSAGE_MANAGE.
Required to actually pin the Message.
- Missing
-
unpin
@Nonnull @CheckReturnValue RestAction<Void> unpin()
Used to remove the Message from theMessageChannel'spinned message list.
This is a shortcut method toMessageChannel.unpinMessageById(String).The success or failure of this action will not affect the return of
isPinned().The following
ErrorResponsesare possible:MISSING_ACCESS
The unpin request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The unpin request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannel.UNKNOWN_MESSAGEThe unpin request was attempted after the Message had been deleted.
- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If this Message is from aTextChanneland:- Missing
Permission.MESSAGE_READ.
The account needs access the the channel to pin a message in it. - Missing
Permission.MESSAGE_MANAGE.
Required to actually pin the Message.
- Missing
-
addReaction
@Nonnull @CheckReturnValue RestAction<Void> addReaction(@Nonnull Emote emote)
Adds a reaction to this Message using anEmote.This message instance will not be updated by this operation.
Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.
Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.Unicode emojis are not included as
Emote!The following
ErrorResponsesare possible:MISSING_ACCESS
The reaction request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYREACTION_BLOCKED
The user has blocked the currently logged in account and the reaction failedTOO_MANY_REACTIONS
The message already has too many reactions to proceedMISSING_PERMISSIONS
The reaction request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONorPermission.MESSAGE_HISTORYin theTextChannelwhen adding the reaction.UNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
emote- TheEmoteto add as a reaction to this Message.- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not haveIllegalArgumentException-- If the provided
Emoteis null. - If the provided
Emoteis fakeEmote.isFake(). - If the provided
Emotecannot be used in the current channel. SeeEmote.canInteract(User, MessageChannel)orEmote.canInteract(Member)for more information.
- If the provided
-
addReaction
@Nonnull @CheckReturnValue RestAction<Void> addReaction(@Nonnull String unicode)
Adds a reaction to this Message using a unicode emoji.
A reference of unicode emojis can be found here: Emoji Table.This message instance will not be updated by this operation.
Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.
Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.Examples
// custom
message.addReaction("minn:245267426227388416").queue();
// unicode escape
message.addReaction("\uD83D\uDE02").queue();
// codepoint notation
message.addReaction("U+1F602").queue();The following
ErrorResponsesare possible:MISSING_ACCESS
The reaction request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYREACTION_BLOCKED
The user has blocked the currently logged in account and the reaction failedTOO_MANY_REACTIONS
The message already has too many reactions to proceedMISSING_PERMISSIONS
The reaction request was attempted after the account lostPermission.MESSAGE_ADD_REACTIONin theTextChannelwhen adding the reaction.UNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
unicode- The unicode emoji to add as a reaction to this Message.- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not haveIllegalArgumentException- If the provided unicode emoji is null or empty.
-
clearReactions
@Nonnull @CheckReturnValue RestAction<Void> clearReactions()
Removes all reactions from this Message.
This is useful for moderator commands that wish to remove all reactions at once from a specific message.Please note that you can't clear reactions if this message was sent in a
PrivateChannel!Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.The following
ErrorResponsesare possible:MISSING_ACCESS
The clear-reactions request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The clear-reactions request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen adding the reaction.UNKNOWN_MESSAGEThe clear-reactions request was attempted after the Message had been deleted.
- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the currently logged in account does not havePermission.MESSAGE_MANAGEin the channel.IllegalStateException- If this message was not sent in aGuild.
-
clearReactions
@Nonnull @CheckReturnValue RestAction<Void> clearReactions(@Nonnull String unicode)
Removes all reactions for the specified emoji.Please note that you can't clear reactions if this message was sent in a
PrivateChannel!Example
// custom message.clearReactions("minn:245267426227388416").queue(); // unicode escape message.clearReactions("\uD83D\uDE02").queue(); // codepoint notation message.clearReactions("U+1F602").queue();The following
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGE
The message was deleted.
- Parameters:
unicode- The unicode emoji to remove reactions for- Returns:
RestAction- Throws:
UnsupportedOperationException- If this reaction happened in a private channelInsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin the channelIllegalArgumentException- If provided with nullIllegalStateException- If this message was not sent in aGuild.- Since:
- 4.2.0
-
clearReactions
@Nonnull @CheckReturnValue RestAction<Void> clearReactions(@Nonnull Emote emote)
Removes all reactions for the specified emote.Please note that you can't clear reactions if this message was sent in a
PrivateChannel!The following
ErrorResponsesare possible:MISSING_ACCESS
The currently logged in account lost access to the channel by either being removed from the guild or losing theVIEW_CHANNELpermissionUNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGE
The message was deleted.
- Parameters:
emote- TheEmoteto remove reactions for- Returns:
RestAction- Throws:
UnsupportedOperationException- If this reaction happened in a private channelInsufficientPermissionException- If the currently logged in account does not havePermission.MESSAGE_MANAGEin the channelIllegalArgumentException- If provided with nullIllegalStateException- If this message was not sent in aGuild.- Since:
- 4.2.0
-
removeReaction
@Nonnull @CheckReturnValue RestAction<Void> removeReaction(@Nonnull Emote emote)
Removes a reaction from this Message using anEmote.This message instance will not be updated by this operation.
Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.
Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.Unicode emojis are not included as
Emote!The following
ErrorResponsesare possible:MISSING_ACCESS
The reaction request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
emote- TheEmoteto remove as a reaction from this Message.- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORYIllegalArgumentException-- If the provided
Emoteis null. - If the provided
Emotecannot be used in the current channel. SeeEmote.canInteract(User, MessageChannel)orEmote.canInteract(Member)for more information.
- If the provided
- Since:
- 4.1.0
-
removeReaction
@Nonnull @CheckReturnValue RestAction<Void> removeReaction(@Nonnull Emote emote, @Nonnull User user)
Removes aUser'sreaction from this Message using anEmote.Please note that you can't remove reactions of other users if this message was sent in a
PrivateChannel!This message instance will not be updated by this operation.
Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/emote.
Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.Unicode emojis are not included as
Emote!The following
ErrorResponsesare possible:MISSING_ACCESS
The reaction request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYMISSING_PERMISSIONS
The reaction request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen removing the reaction.UNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
emote- TheEmoteto remove as a reaction from this Message.user- TheUserto remove the reaction for.- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORY.IllegalArgumentException-- If the provided
Emoteis null. - If the provided
Emoteis fakeEmote.isFake(). - If the provided
Emotecannot be used in the current channel. SeeEmote.canInteract(User, MessageChannel)orEmote.canInteract(Member)for more information. - If the provided user is null
- If the provided
IllegalStateException- If this message was not sent in aGuildand the given user is not theSelfUser.- Since:
- 4.1.0
-
removeReaction
@Nonnull @CheckReturnValue RestAction<Void> removeReaction(@Nonnull String unicode)
Removes a reaction from this Message using a unicode emoji.
A reference of unicode emojis can be found here: Emoji Table.This message instance will not be updated by this operation.
Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/unicode.
Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.Examples
// custom
message.removeReaction("minn:245267426227388416").queue();
// unicode escape
message.removeReaction("\uD83D\uDE02").queue();
// codepoint notation
message.removeReaction("U+1F602").queue();The following
ErrorResponsesare possible:MISSING_ACCESS
The reaction request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
unicode- The unicode emoji to add as a reaction to this Message.- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORYIllegalArgumentException- If the provided unicode emoji is null or empty.- Since:
- 4.1.0
-
removeReaction
@Nonnull @CheckReturnValue RestAction<Void> removeReaction(@Nonnull String unicode, @Nonnull User user)
Removes a reaction from this Message using a unicode emoji.
A reference of unicode emojis can be found here: Emoji Table.Please note that you can't remove reactions of other users if this message was sent in a
PrivateChannel!This message instance will not be updated by this operation.
Reactions are the small emoji/emotes below a message that have a counter beside them showing how many users have reacted with the same emoji/unicode.
Neither success nor failure of this request will affect this Message's
getReactions()return as Message is immutable.The following
ErrorResponsesare possible:MISSING_ACCESS
The reaction request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableMISSING_PERMISSIONS
The reaction request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen removing the reaction.UNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
unicode- The unicode emoji to add as a reaction to this Message.user- TheUserto remove the reaction for.- Returns:
RestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not haveIllegalArgumentException- If the provided unicode emoji is null or empty or if the provided user is null.IllegalStateException- If this message was not sent in aGuildand the given user is not theSelfUser.- Since:
- 4.1.0
-
retrieveReactionUsers
@Nonnull @CheckReturnValue ReactionPaginationAction retrieveReactionUsers(@Nonnull Emote emote)
This obtains theuserswho reacted using the givenemote.Messages maintain a list of reactions, alongside a list of users who added them.
Using this data, we can obtain a
ReactionPaginationActionof the users who've reacted to this message.The following
ErrorResponsesare possible:MISSING_ACCESS
The retrieve request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided emote was deleted, doesn't exist, or is not available to the currently logged-in account in this channel.UNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
emote- Theemoteto retrieve users for.- Returns:
- The
ReactionPaginationActionof the emote's users. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORYin the channel.IllegalArgumentException- If the providedEmoteis null.- Since:
- 4.1.0
-
retrieveReactionUsers
@Nonnull @CheckReturnValue ReactionPaginationAction retrieveReactionUsers(@Nonnull String unicode)
This obtains theuserswho reacted using the given unicode emoji.Messages maintain a list of reactions, alongside a list of users who added them.
Using this data, we can obtain a
ReactionPaginationActionof the users who've reacted to this message.The following
ErrorResponsesare possible:MISSING_ACCESS
The retrieve request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked
Also can happen if the account lost thePermission.MESSAGE_HISTORYUNKNOWN_EMOJI
The provided unicode character does not refer to a known emoji unicode character.
Proper unicode characters for emojis can be found here: Emoji TableUNKNOWN_MESSAGEThe reaction request was attempted after the Message had been deleted.
- Parameters:
unicode- The unicode emote to retrieve users for.- Returns:
- The
ReactionPaginationActionof the emoji's users. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the logged in account does not havePermission.MESSAGE_HISTORYin the channel.IllegalArgumentException- If the provided unicode emoji is null or empty.- Since:
- 4.1.0
-
getReactionByUnicode
@Nullable @CheckReturnValue MessageReaction.ReactionEmote getReactionByUnicode(@Nonnull String unicode)
This obtains theReactionEmotefor the given unicode reaction on this message.Messages also store reactions using unicode values.
An instance of the related
ReactionEmotecan be obtained through this method by using the emoji's unicode value.- Parameters:
unicode- The unicode value of the reaction emoji.- Returns:
- The
ReactionEmoteof this message or null if not present. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalArgumentException- If the provided unicode value is null or empty.- Since:
- 4.1.0
-
getReactionById
@Nullable @CheckReturnValue MessageReaction.ReactionEmote getReactionById(@Nonnull String id)
This obtains theReactionEmotefor the given reaction id on this message.Messages store reactions by keeping a list of reaction names.
An instance of the related
ReactionEmotecan be obtained through this method by using the emote's id.- Parameters:
id- The string id of the reaction emote.- Returns:
- The
ReactionEmoteof this message or null if not present. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTIllegalArgumentException- If the provided id is not a valid snowflake.- Since:
- 4.1.0
-
getReactionById
@Nullable @CheckReturnValue MessageReaction.ReactionEmote getReactionById(long id)
This obtains theReactionEmotefor the given reaction id on this message.Messages store reactions by keeping a list of reaction names.
An instance of the related
ReactionEmotecan be obtained through this method by using the emote's id.- Parameters:
id- The long id of the reaction emote.- Returns:
- The
ReactionEmoteof this message or null if not present. - Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT- Since:
- 4.1.0
-
suppressEmbeds
@Nonnull @CheckReturnValue AuditableRestAction<Void> suppressEmbeds(boolean suppressed)
Enables/Disables suppression of Embeds on this Message.
Suppressing Embeds is equivalent to pressing theXin the top-right corner of an Embed inside the Discord client.The following
ErrorResponsesare possible:MISSING_ACCESS
The clear-reactions request was attempted after the account lost access to theTextChanneldue toPermission.MESSAGE_READbeing revoked, or the account lost access to theGuildtypically due to being kicked or removed.MISSING_PERMISSIONS
The suppress-embeds request was attempted after the account lostPermission.MESSAGE_MANAGEin theTextChannelwhen adding the reaction.UNKNOWN_MESSAGEThe suppress-embeds request was attempted after the Message had been deleted.
- Parameters:
suppressed- Whether or not the embed should be suppressed- Returns:
AuditableRestAction- Type:Void- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULTInsufficientPermissionException- If the MessageChannel this message was sent in was aTextChanneland the currently logged in account does not havePermission.MESSAGE_MANAGEin the channel.PermissionException- If the MessageChannel this message was sent in was aPrivateChanneland the message was not sent by the currently logged in account.- See Also:
isSuppressedEmbeds()
-
isSuppressedEmbeds
boolean isSuppressedEmbeds()
Whether embeds are suppressed for this message. When Embeds are suppressed, they are not displayed on clients nor provided via API until un-suppressed.
This is a shortcut method for checking ifgetFlags()containsMessageFlag#EMBEDS_SUPPRESSED- Returns:
- Whether or not Embeds are suppressed for this Message.
- Throws:
UnsupportedOperationException- If this is not a Received Message fromMessageType.DEFAULT- See Also:
suppressEmbeds(boolean)
-
getFlags
@Nonnull EnumSet<Message.MessageFlag> getFlags()
Returns an EnumSet of allMessageFlagspresent for this Message.- Returns:
- Never-Null EnumSet of present
MessageFlags - See Also:
Message.MessageFlag
-
getType
@Nonnull MessageType getType()
This specifies theMessageTypeof this Message.Messages can represent more than just simple text sent by Users, they can also be special messages that inform about events that occur. Messages can either be
default messagesor special messages likewelcome messages.- Returns:
- The
MessageTypeof this message.
-
-