public final class Message extends Object implements Entity
Modifier and Type | Class and Description |
---|---|
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(ServiceMediator serviceMediator,
MessageBean 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.
|
Snowflake |
getChannelId()
Gets the ID of the channel the message was sent in.
|
DiscordClient |
getClient()
Gets the DiscordClient associated to this object.
|
Optional<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.
|
Mono<Guild> |
getGuild()
Requests to retrieve the guild this message is associated to, if present.
|
Snowflake |
getId()
Gets the Snowflake that uniquely identifies this entity.
|
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.
|
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.
|
Instant |
getTimestamp()
Gets when this message was sent.
|
Message.Type |
getType()
Gets the type of 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.
|
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> |
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> |
removeSelfReaction(ReactionEmoji emoji)
Requests to remove a reaction from the current user on this message.
|
String |
toString() |
Mono<Void> |
unpin()
Requests to unpin this message.
|
public static final int MAX_CONTENT_LENGTH
public Message(ServiceMediator serviceMediator, MessageBean data)
Message
with an associated ServiceMediator and Discord data.serviceMediator
- The ServiceMediator associated to this object, must be non-null.data
- The raw data as represented by Discord, must be non-null.public DiscordClient getClient()
DiscordObject
getClient
in interface DiscordObject
public Snowflake getId()
Entity
public Snowflake getChannelId()
public Mono<MessageChannel> getChannel()
public Optional<Snowflake> getWebhookId()
public Optional<User> getAuthor()
public Mono<Member> getAuthorAsMember()
member
of the guild in which it was sent.public Optional<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 Set<Snowflake> getRoleMentionIds()
public Flux<Role> getRoleMentions()
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 Mono<Guild> getGuild()
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
.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> 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
.