public interface MessageChannel extends Channel
Channel.Type
Modifier and Type | Method and Description |
---|---|
default Mono<Message> |
createEmbed(Consumer<? super EmbedCreateSpec> spec)
Requests to create a message with only an
MessageCreateSpec.setEmbed(Consumer) . |
Mono<Message> |
createMessage(Consumer<? super MessageCreateSpec> spec)
Requests to create a message.
|
default Mono<Message> |
createMessage(String message)
Requests to create a message with only
content . |
Mono<Message> |
getLastMessage()
Requests to retrieve the last message sent in this channel, if present.
|
Mono<Message> |
getLastMessage(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the last message sent in this channel, if present, using the given retrieval strategy.
|
Optional<Snowflake> |
getLastMessageId()
Gets the ID of the last message sent in this channel, if present.
|
Optional<Instant> |
getLastPinTimestamp()
Gets when the last pinned message was pinned, if present.
|
Mono<Message> |
getMessageById(Snowflake id)
Requests to retrieve the message as represented by the supplied ID.
|
Mono<Message> |
getMessageById(Snowflake id,
EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the message as represented by the supplied ID, using the given retrieval strategy.
|
Flux<Message> |
getMessagesAfter(Snowflake messageId)
Requests to retrieve all messages after the specified ID.
|
Flux<Message> |
getMessagesBefore(Snowflake messageId)
Requests to retrieve all messages before the specified ID.
|
Flux<Message> |
getPinnedMessages()
Requests to retrieve all the pinned messages for this channel.
|
Mono<Void> |
type()
Requests to trigger the typing indicator in this channel.
|
Flux<Long> |
typeUntil(Publisher<?> until)
Requests to trigger the typing indicator in this channel.
|
delete, delete, getMention, getRestChannel, getType
getClient
Optional<Snowflake> getLastMessageId()
Mono<Message> getLastMessage()
Mono<Message> getLastMessage(EntityRetrievalStrategy retrievalStrategy)
Optional<Instant> getLastPinTimestamp()
Mono<Message> createMessage(Consumer<? super MessageCreateSpec> spec)
spec
- A Consumer
that provides a "blank" MessageCreateSpec
to be operated on.Mono
where, upon successful completion, emits the created Message
. If an error is
received, it is emitted through the Mono
.default Mono<Message> createMessage(String message)
content
.message
- A string message to populate the message with.Mono
where, upon successful completion, emits the created Message
. If an error is
received, it is emitted through the Mono
.MessageCreateSpec.setContent(String)
default Mono<Message> createEmbed(Consumer<? super EmbedCreateSpec> spec)
MessageCreateSpec.setEmbed(Consumer)
.spec
- A Consumer
that provides a "blank" EmbedCreateSpec
to be operated on.Mono
where, upon successful completion, emits the created Message
. If an error is
received, it is emitted through the Mono
.Mono<Void> type()
Mono
which completes upon successful triggering of the typing indicator in this channel. If
an error is received, it is emitted through the Mono
.Flux<Long> typeUntil(Publisher<?> until)
This method cannot stop the typing indicator during the 10 second duration. It simply checks every 10 seconds whether to trigger the indicator again depending on if the publisher emitted. For example, the following code will show the typing indicator for 10 seconds, not 5:
channel.typeUntil(Mono.delay(Duration.ofSeconds(5))
The only way to stop the typing indicator during the 10 second duration is to send a message in the channel. For example, the following code will show the typing indicator until the message is sent:
channel.typeUntil(channel.createMessage("Hello"))
until
- The companion Publisher
that signals when to stop triggering the typing indicator.Flux
which continually emits each time the typing indicator is triggered and completes when it
will no longer be triggered. If an error is received, it is emitted through the Flux
.Flux<Message> getMessagesBefore(Snowflake messageId)
The returned Flux
will emit items in reverse-chronological order (newest to oldest). It is
recommended to limit the emitted items by invoking either Flux.takeWhile(Predicate)
(to retrieve IDs
within a specified range) or Flux.take(long)
(to retrieve a specific amount of IDs).
The following example will get all messages from messageId
to myOtherMessageId
:
getMessagesBefore(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) >= 0)
messageId
- The ID of the newest message to retrieve. Use Snowflake.of(Instant)
to retrieve a
time-based ID.Flux
that continually emits all messages
before the specified ID.
If an error is received, it is emitted through the Flux
.Flux<Message> getMessagesAfter(Snowflake messageId)
The returned Flux
will emit items in chronological order (oldest to newest). It is recommended to limit
the emitted items by invoking either Flux.takeWhile(Predicate)
(to retrieve IDs within a specified range)
or Flux.take(long)
(to retrieve a specific amount of IDs).
The following example will get all messages from messageId
to myOtherMessageId
:
getMessagesAfter(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) <= 0)
messageId
- The ID of the oldest message to retrieve. Use Snowflake.of(Instant)
to retrieve a
time-based ID.Flux
that continually emits all messages
after the specified ID.
If an error is received, it is emitted through the Flux
.Mono<Message> getMessageById(Snowflake id)
Mono<Message> getMessageById(Snowflake id, EntityRetrievalStrategy retrievalStrategy)