Package discord4j.rest.entity
Class RestMessage
- java.lang.Object
-
- discord4j.rest.entity.RestMessage
-
public class RestMessage extends Object
Represents a message within Discord.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RestChannel
channel()
static RestMessage
create(RestClient restClient, Snowflake channelId, Snowflake id)
Create aRestMessage
with the given parameters.Mono<Void>
createReaction(String emoji)
Requests to add a reaction on this message.Mono<Void>
delete(String reason)
Requests to delete this message while optionally specifying a reason.Mono<Void>
deleteAllReactions()
Requests to remove all the reactions on this message.Mono<Void>
deleteOwnReaction(String emoji)
Requests to remove a reaction from the current user on this message.Mono<Void>
deleteReactions(String emoji)
Requests to remove a specified reaction on this message.Mono<Void>
deleteUserReaction(String emoji, Snowflake userId)
Requests to remove a reaction from a specified user on this message.Mono<discord4j.discordjson.json.MessageData>
edit(discord4j.discordjson.json.MessageEditRequest request)
Requests to edit this message.Snowflake
getChannelId()
Returns the ID of the channel this message belongs to.Mono<discord4j.discordjson.json.MessageData>
getData()
Retrieve this messages' data upon subscription.Snowflake
getId()
Returns the ID of this message.Mono<discord4j.discordjson.json.MessageData>
publish()
Requests to publish (crosspost) this message if thechannel
is of type 'news'.
-
-
-
Method Detail
-
create
public static RestMessage create(RestClient restClient, Snowflake channelId, Snowflake id)
Create aRestMessage
with the given parameters. This method does not perform any API request.- Parameters:
restClient
- REST API resourceschannelId
- the ID of the channel this messages belongs toid
- the ID of this message- Returns:
- a
RestMessage
represented by the given parameters.
-
getChannelId
public Snowflake getChannelId()
Returns the ID of the channel this message belongs to.- Returns:
- The ID of the channel this message belongs to
-
getId
public Snowflake getId()
Returns the ID of this message.- Returns:
- The ID of this message
-
channel
public RestChannel channel()
-
getData
public Mono<discord4j.discordjson.json.MessageData> getData()
Retrieve this messages' data upon subscription.- Returns:
- a
Mono
where, upon successful completion, emits theMessageData
belonging to this channel. If an error is received, it is emitted through theMono
. - See Also:
- Get Message
-
createReaction
public Mono<Void> createReaction(String emoji)
Requests to add a reaction on this message.- Parameters:
emoji
- The reaction to add on this message. emoji takes the form of name:id for custom guild emoji, or Unicode characters.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the reaction was added on this message. If an error is received, it is emitted through theMono
. - See Also:
- Create Reaction
-
deleteOwnReaction
public Mono<Void> deleteOwnReaction(String emoji)
Requests to remove a reaction from the current user on this message.- Parameters:
emoji
- The reaction to remove on this message.- Returns:
- A
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 theMono
. - See Also:
- Delete Own Reaction
-
deleteUserReaction
public Mono<Void> deleteUserReaction(String emoji, Snowflake userId)
Requests to remove a reaction from a specified user on this message.- Parameters:
emoji
- The reaction to remove on this message.userId
- The user to remove the reaction on this message.- Returns:
- A
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 theMono
. - See Also:
- Delete User Reaction
-
deleteAllReactions
public Mono<Void> deleteAllReactions()
Requests to remove all the reactions on this message.- Returns:
- A
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 theMono
. - See Also:
- Delete All Reactions
-
deleteReactions
public Mono<Void> deleteReactions(String emoji)
Requests to remove a specified reaction on this message.- Parameters:
emoji
- The reaction to remove on this message.- Returns:
- A
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 theMono
. - See Also:
- Delete All Reactions for Emoji
-
edit
public Mono<discord4j.discordjson.json.MessageData> edit(discord4j.discordjson.json.MessageEditRequest request)
Requests to edit this message.- Parameters:
request
- The request body used to create a new message.- Returns:
- A
Mono
where, upon successful completion, emits the editedMessageData
. If an error is received, it is emitted through theMono
. - See Also:
- Edit Message
-
delete
public Mono<Void> delete(@Nullable String reason)
Requests to delete this message while optionally specifying a reason.- Parameters:
reason
- The reason, if present.- Returns:
- A
Mono
where, upon successful completion, emits nothing; indicating the message has been deleted. If an error is received, it is emitted through theMono
. - See Also:
- Delete Message
-
publish
public Mono<discord4j.discordjson.json.MessageData> publish()
Requests to publish (crosspost) this message if thechannel
is of type 'news'. Requires 'SEND_MESSAGES' permission if the current user sent the message, or additionally the 'MANAGE_MESSAGES' permission, for all other messages, to be present for the current user.- Returns:
- A
Mono
where, upon successful completion, emits the publishedMessageData
(crossposted) in the guilds. If an error is received, it is emitted through theMono
. - See Also:
- Crosspost Message
-
-