public final class PrivateChannel extends Object
Channel.Type
Constructor and Description |
---|
PrivateChannel(GatewayDiscordClient gateway,
discord4j.discordjson.json.ChannelData 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) |
GatewayDiscordClient |
getClient()
Returns the
GatewayDiscordClient that created 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.
|
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.
|
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.
|
Flux<User> |
getRecipients(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the recipients for this private channel, using the given retrieval strategy.
|
RestChannel |
getRestChannel()
Return a
RestChannel handle to execute REST API operations on this entity. |
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, getRestChannel, getType
getClient
public PrivateChannel(GatewayDiscordClient gateway, discord4j.discordjson.json.ChannelData data)
PrivateChannel
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 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 Flux<User> getRecipients(EntityRetrievalStrategy retrievalStrategy)
retrievalStrategy
- the strategy to use to get the recipientsFlux
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 Mono<Message> getLastMessage(EntityRetrievalStrategy retrievalStrategy)
MessageChannel
getLastMessage
in interface MessageChannel
retrievalStrategy
- the strategy to use to get the last messageMono
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 Mono<Message> getMessageById(Snowflake id, EntityRetrievalStrategy retrievalStrategy)
MessageChannel
getMessageById
in interface MessageChannel
id
- The ID of the message.retrievalStrategy
- the strategy to use to get the messageMono
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 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 final Snowflake getId()
Entity
public RestChannel getRestChannel()
Channel
RestChannel
handle to execute REST API operations on this entity.getRestChannel
in interface Channel
public final Channel.Type getType()
Channel
public final Mono<Void> delete(@Nullable String reason)
Channel