public final class PrivateChannel extends Object
Channel.Type
Constructor and Description |
---|
PrivateChannel(ServiceMediator serviceMediator,
ChannelBean data)
Constructs an
PrivateChannel with an associated ServiceMediator and Discord data. |
Modifier and Type | Method and Description |
---|---|
Mono<Message> |
createMessage(Consumer<? super MessageCreateSpec> spec)
Requests to create a message.
|
Mono<Void> |
delete(String reason)
Requests to delete this channel while optionally specifying a reason.
|
boolean |
equals(Object obj) |
DiscordClient |
getClient()
Gets the DiscordClient associated to this object.
|
Snowflake |
getId()
Gets the Snowflake that uniquely identifies this entity.
|
Mono<Message> |
getLastMessage()
Requests to retrieve the last message sent in this channel, if present.
|
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.
|
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.
|
Set<Snowflake> |
getRecipientIds()
Gets the IDs of the recipients for this private channel.
|
Flux<User> |
getRecipients()
Requests to retrieve the recipients for this private channel.
|
Channel.Type |
getType()
Gets the type of channel.
|
int |
hashCode() |
String |
toString() |
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
createEmbed, createMessage
delete, delete, getMention, getType
getClient
public PrivateChannel(ServiceMediator serviceMediator, ChannelBean data)
PrivateChannel
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 Set<Snowflake> getRecipientIds()
public Flux<User> getRecipients()
Flux
that continually emits the recipients
for this private channel. If an error
is received, it is emitted through the Flux
.public String toString()
public final Optional<Snowflake> getLastMessageId()
MessageChannel
getLastMessageId
in interface MessageChannel
public final Mono<Message> getLastMessage()
MessageChannel
getLastMessage
in interface MessageChannel
Mono
where, upon successful completion, emits the last message
sent in this
channel, if present. If an error is received, it is emitted through the Mono
.public final Optional<Instant> getLastPinTimestamp()
MessageChannel
getLastPinTimestamp
in interface MessageChannel
public final Mono<Message> createMessage(Consumer<? super MessageCreateSpec> spec)
MessageChannel
createMessage
in interface MessageChannel
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
.public final Mono<Void> type()
MessageChannel
type
in interface MessageChannel
Mono
which completes upon successful triggering of the typing indicator in this channel. If
an error is received, it is emitted through the Mono
.public final Flux<Long> typeUntil(Publisher<?> until)
MessageChannel
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"))
typeUntil
in interface MessageChannel
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
.public final Flux<Message> getMessagesBefore(Snowflake messageId)
MessageChannel
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)
getMessagesBefore
in interface MessageChannel
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
.public final Flux<Message> getMessagesAfter(Snowflake messageId)
MessageChannel
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)
getMessagesAfter
in interface MessageChannel
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
.public final Mono<Message> getMessageById(Snowflake id)
MessageChannel
getMessageById
in interface MessageChannel
id
- The ID of the message.Mono
where, upon successful completion, emits the Message
as represented by the
supplied ID. If an error is received, it is emitted through the Mono
.public final Flux<Message> getPinnedMessages()
MessageChannel
getPinnedMessages
in interface MessageChannel
Flux
that continually emits all the pinned messages for this channel. If an error is received,
it is emitted through the Flux
.public final DiscordClient getClient()
DiscordObject
getClient
in interface DiscordObject
public final Snowflake getId()
Entity
public final Channel.Type getType()
Channel
public final Mono<Void> delete(@Nullable String reason)
Channel