public final class Message extends Object implements Entity
Modifier and Type | Class and Description |
---|---|
static class |
Message.Flag
Describes extra features of a message.
|
static class |
Message.Type
Represents the various types of messages.
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CONTENT_LENGTH
The maximum amount of characters that can be in the contents of a message.
|
Constructor and Description |
---|
Message(GatewayDiscordClient gateway,
discord4j.discordjson.json.MessageData data)
Constructs a
Message with an associated ServiceMediator and Discord data. |
Modifier and Type | Method and Description |
---|---|
Mono<Void> |
addReaction(ReactionEmoji emoji)
Requests to add a reaction on this message.
|
Mono<Void> |
delete()
Requests to delete this message.
|
Mono<Void> |
delete(String reason)
Requests to delete this message while optionally specifying a reason.
|
Mono<Message> |
edit(Consumer<? super MessageEditSpec> spec)
Requests to edit this message.
|
boolean |
equals(Object obj) |
Set<Attachment> |
getAttachments()
Gets any attached files.
|
Optional<User> |
getAuthor()
Gets the author of this message, if present.
|
Mono<Member> |
getAuthorAsMember()
Requests to retrieve the author of this message as a
member of the guild in which it was sent. |
Mono<MessageChannel> |
getChannel()
Requests to retrieve the channel the message was sent in.
|
Mono<MessageChannel> |
getChannel(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the channel the message was sent in, using the given retrieval strategy.
|
Snowflake |
getChannelId()
Gets the ID of the channel the message was sent in.
|
GatewayDiscordClient |
getClient()
Returns the
GatewayDiscordClient that created this object. |
String |
getContent()
Gets the contents of the message, if present.
|
Optional<Instant> |
getEditedTimestamp()
Gets when this message was edited, if present.
|
List<Embed> |
getEmbeds()
Gets any embedded content.
|
EnumSet<Message.Flag> |
getFlags()
Returns the flags of this
Message , describing its features. |
Mono<Guild> |
getGuild()
Requests to retrieve the guild this message is associated to, if present.
|
Mono<Guild> |
getGuild(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the guild this message is associated to, if present, using the given retrieval strategy.
|
Optional<Snowflake> |
getGuildId()
Gets the ID of the guild this message is associated to, if present.
|
Snowflake |
getId()
Gets the Snowflake that uniquely identifies this entity.
|
Optional<MessageReference> |
getMessageReference()
Returns the
MessageReference in this message (Server Following feature), if present. |
Set<Reaction> |
getReactions()
Gets the reactions to this message.
|
Flux<User> |
getReactors(ReactionEmoji emoji)
Requests to retrieve the reactors (users) for the specified emoji for this message.
|
RestChannel |
getRestChannel() |
RestMessage |
getRestMessage() |
Set<Snowflake> |
getRoleMentionIds()
Gets the IDs of the roles specifically mentioned in this message.
|
Flux<Role> |
getRoleMentions()
Requests to retrieve the roles specifically mentioned in this message.
|
Flux<Role> |
getRoleMentions(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the roles specifically mentioned in this message, using the given retrieval strategy.
|
Instant |
getTimestamp()
Gets when this message was sent.
|
Message.Type |
getType()
Gets the type of message.
|
discord4j.discordjson.json.UserData |
getUserData()
Gets the raw author data of this message.
|
Set<Snowflake> |
getUserMentionIds()
Gets the IDs of the users specifically mentioned in this message.
|
Flux<User> |
getUserMentions()
Requests to retrieve the users specifically mentioned in this message.
|
Flux<User> |
getUserMentions(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the users specifically mentioned in this message, using the given retrieval strategy.
|
Mono<Webhook> |
getWebhook()
Requests to retrieve the webhook that generated this message, if present.
|
Optional<Snowflake> |
getWebhookId()
Gets the ID the webhook that generated this message, if present.
|
int |
hashCode() |
boolean |
isPinned()
Gets whether this message is pinned.
|
boolean |
isTts()
Gets whether this was a TTS (Text-To-Speech) message.
|
boolean |
mentionsEveryone()
Gets whether this message mentions everyone.
|
Mono<Void> |
pin()
Requests to pin this message.
|
Mono<Void> |
publish()
Requests to publish (crosspost) this message if the
channel is of type 'news'. |
Mono<Void> |
removeAllReactions()
Requests to remove all the reactions on this message.
|
Mono<Void> |
removeReaction(ReactionEmoji emoji,
Snowflake userId)
Requests to remove a reaction from a specified user on this message.
|
Mono<Void> |
removeReactions(ReactionEmoji emoji)
Requests to remove all reactions of a specific emoji on this message.
|
Mono<Void> |
removeSelfReaction(ReactionEmoji emoji)
Requests to remove a reaction from the current user on this message.
|
Mono<Void> |
suppressEmbeds(boolean suppress)
Requests to suppress all embeds in this message.
|
String |
toString() |
Mono<Void> |
unpin()
Requests to unpin this message.
|
public static final int MAX_CONTENT_LENGTH
public Message(GatewayDiscordClient gateway, discord4j.discordjson.json.MessageData data)
Message
with an associated ServiceMediator and Discord data.gateway
- The GatewayDiscordClient
associated to this object, must be non-null.data
- The raw data as represented by Discord, must be non-null.public GatewayDiscordClient getClient()
DiscordObject
GatewayDiscordClient
that created this object. Methods in it are exclusively based on the
entity cache or Store
in use. Refer to calling getClient().rest()
to access a
DiscordClient
that is capable of requesting entities directly from the REST API.getClient
in interface DiscordObject
GatewayDiscordClient
associated to this object.public Snowflake getId()
Entity
public RestMessage getRestMessage()
RestMessage
handle to execute REST API operations on this entity.public RestChannel getRestChannel()
RestChannel
handle to execute REST API operations on the channel of this message.public Snowflake getChannelId()
public Mono<MessageChannel> getChannel()
public Mono<MessageChannel> getChannel(EntityRetrievalStrategy retrievalStrategy)
public Optional<Snowflake> getWebhookId()
public Optional<User> getAuthor()
public Mono<Member> getAuthorAsMember()
member
of the guild in which it was sent.@Experimental public discord4j.discordjson.json.UserData getUserData()
public String getContent()
public Instant getTimestamp()
public Optional<Instant> getEditedTimestamp()
public boolean isTts()
true
if this message was a TTS (Text-To-Speech) message, false
otherwise.public boolean mentionsEveryone()
true
if this message mentions everyone, false
otherwise.public Set<Snowflake> getUserMentionIds()
public Flux<User> getUserMentions()
public Flux<User> getUserMentions(EntityRetrievalStrategy retrievalStrategy)
public Set<Snowflake> getRoleMentionIds()
public Flux<Role> getRoleMentions()
public Flux<Role> getRoleMentions(EntityRetrievalStrategy retrievalStrategy)
public Set<Attachment> getAttachments()
public Set<Reaction> getReactions()
public Flux<User> getReactors(ReactionEmoji emoji)
public boolean isPinned()
true
if this message is pinned, false
otherwise.public Mono<Webhook> getWebhook()
public Optional<MessageReference> getMessageReference()
MessageReference
in this message (Server Following feature), if present.MessageReference
, if present.public EnumSet<Message.Flag> getFlags()
Message
, describing its features.EnumSet
with the flags of this message.public Optional<Snowflake> getGuildId()
public Mono<Guild> getGuild()
public Mono<Guild> getGuild(EntityRetrievalStrategy retrievalStrategy)
public Message.Type getType()
public Mono<Message> edit(Consumer<? super MessageEditSpec> spec)
spec
- A Consumer
that provides a "blank" MessageEditSpec
to be operated on.Mono
where, upon successful completion, emits the edited Message
. If an error is
received, it is emitted through the Mono
.public Mono<Void> delete()
Mono
where, upon successful completion, emits nothing; indicating the message has been deleted.
If an error is received, it is emitted through the Mono
.public Mono<Void> delete(@Nullable String reason)
reason
- The reason, if present.Mono
where, upon successful completion, emits nothing; indicating the message has been deleted.
If an error is received, it is emitted through the Mono
.@Experimental public Mono<Void> suppressEmbeds(boolean suppress)
suppress
- Determine if you need suppress or not the embeds.Mono
where, upon successful completion, emits nothing; indicating the process has been
completed. If an error is received, it is emitted through the Mono
.public Mono<Void> addReaction(ReactionEmoji emoji)
emoji
- The reaction to add on this message.Mono
where, upon successful completion, emits nothing; indicating the reaction was added on
this message. If an error is received, it is emitted through the Mono
.public Mono<Void> removeReaction(ReactionEmoji emoji, Snowflake userId)
emoji
- The reaction to remove on this message.userId
- The user to remove the reaction on this message.Mono
where, upon successful completion, emits nothing; indicating the reaction from the
specified user was removed on this message. If an error is received, it is emitted through the Mono
.public Mono<Void> removeReactions(ReactionEmoji emoji)
emoji
- The reaction to remove on this messageMono
where, upon successful completion, emits nothing; indicating the reaction from the
specified user was removed on this message. If an error is received, it is emitted through the Mono
.public Mono<Void> removeSelfReaction(ReactionEmoji emoji)
emoji
- The reaction to remove on this message.Mono
where, upon successful completion, emits nothing; indicating the reaction from the current
user was removed on this message. If an error is received, it is emitted through the Mono
.public Mono<Void> removeAllReactions()
Mono
where, upon successful completion, emits nothing; indicating all the reactions on this
message were removed. If an error is received, it is emitted through the Mono
.public Mono<Void> pin()
Mono
where, upon successful completion, emits nothing; indicating the messaged was pinned. If
an error is received, it is emitted through the Mono
.public Mono<Void> unpin()
Mono
where, upon successful completion, emits nothing; indicating the message was unpinned. If
an error is received, it is emitted through the Mono
.@Experimental public Mono<Void> publish()
channel
is of type 'news'.Mono
where, upon successful completion, emits nothing; indicating the message was published
(crossposted) in the guilds. If an error is received, it is emitted through the Mono
.