Interface MessageChannel
- All Superinterfaces:
Channel
,DiscordObject
,Entity
- All Known Subinterfaces:
GuildMessageChannel
,TopLevelGuildMessageChannel
- All Known Implementing Classes:
NewsChannel
,PrivateChannel
,TextChannel
,ThreadChannel
,VoiceChannel
-
Nested Class Summary
Nested classes/interfaces inherited from interface discord4j.core.object.entity.channel.Channel
Channel.Flag, Channel.Type
-
Method Summary
Modifier and TypeMethodDescriptiondefault discord4j.core.spec.MessageCreateMono
createEmbed
(discord4j.core.spec.EmbedCreateSpec embed) Deprecated.createEmbed
(Consumer<? super LegacyEmbedCreateSpec> spec) Deprecated.usecreateEmbed(EmbedCreateSpec)
which offers an immutable approach to build specsdefault discord4j.core.spec.MessageCreateMono
createMessage
(discord4j.core.spec.EmbedCreateSpec... embeds) Requests to create a message with embeds.createMessage
(discord4j.core.spec.MessageCreateSpec spec) Requests to create a message.default discord4j.core.spec.MessageCreateMono
createMessage
(String message) Requests to create a message with a content.createMessage
(Consumer<? super LegacyMessageCreateSpec> spec) Deprecated.usecreateMessage(MessageCreateSpec)
orcreateMessage(String)
which offer an immutable approach to build specsRequests to retrieve the last message sent in this channel, if present.getLastMessage
(EntityRetrievalStrategy retrievalStrategy) Requests to retrieve the last message sent in this channel, if present, using the given retrieval strategy.Gets the ID of the last message sent in this channel, if present.Gets when the last pinned message was pinned, if present.Requests to retrieve the message as represented by the supplied ID.getMessageById
(Snowflake id, EntityRetrievalStrategy retrievalStrategy) Requests to retrieve the message as represented by the supplied ID, using the given retrieval strategy.getMessagesAfter
(Snowflake messageId) Requests to retrieve all messages after the specified ID.getMessagesBefore
(Snowflake messageId) Requests to retrieve all messages before the specified ID.Requests to retrieve all the pinned messages for this channel.type()
Requests to trigger the typing indicator in this channel.Requests to trigger the typing indicator in this channel.Methods inherited from interface discord4j.core.object.entity.channel.Channel
delete, delete, getData, getId, getMention, getRestChannel, getType
Methods inherited from interface discord4j.core.object.DiscordObject
getClient
-
Method Details
-
getLastMessageId
Gets the ID of the last message sent in this channel, if present.- Returns:
- The ID of the last message sent in this channel, if present.
-
getLastMessage
Requests to retrieve the last message sent in this channel, if present. -
getLastMessage
Requests to retrieve the last message sent in this channel, if present, using the given retrieval strategy. -
getLastPinTimestamp
Gets when the last pinned message was pinned, if present.- Returns:
- When the last pinned message was pinned, if present.
-
createMessage
Deprecated.usecreateMessage(MessageCreateSpec)
orcreateMessage(String)
which offer an immutable approach to build specsRequests to create a message.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyMessageCreateSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits the createdMessage
. If an error is received, it is emitted through theMono
.
-
createMessage
Requests to create a message. -
createMessage
Requests to create a message with a content. Other properties specifying how to create the message can be set via thewithXxx
methods of the returnedMessageCreateMono
.- Parameters:
message
- A string message to populate the message with.- Returns:
- A
MessageCreateMono
where, upon successful completion, emits the createdMessage
. If an error is received, it is emitted through theMessageCreateMono
. - See Also:
-
createMessage
default discord4j.core.spec.MessageCreateMono createMessage(discord4j.core.spec.EmbedCreateSpec... embeds) Requests to create a message with embeds. Other properties specifying how to create the message can be set via thewithXxx
methods of the returnedMessageCreateMono
.- Parameters:
embeds
- immutable objects that specify how to create the embeds- Returns:
- A
MessageCreateMono
where, upon successful completion, emits the createdMessage
. If an error is received, it is emitted through theMessageCreateMono
. - See Also:
-
createEmbed
Deprecated.usecreateEmbed(EmbedCreateSpec)
which offers an immutable approach to build specsRequests to create a message with an embed.- Parameters:
spec
- AConsumer
that provides a "blank"LegacyEmbedCreateSpec
to be operated on.- Returns:
- A
Mono
where, upon successful completion, emits the createdMessage
. If an error is received, it is emitted through theMono
.
-
createEmbed
@Deprecated default discord4j.core.spec.MessageCreateMono createEmbed(discord4j.core.spec.EmbedCreateSpec embed) Deprecated.Requests to create a message with an embed. Other properties specifying how to create the message can be set via thewithXxx
methods of the returnedMessageCreateMono
.- Parameters:
embed
- an immutable object that specifies how to create the embed- Returns:
- A
MessageCreateMono
where, upon successful completion, emits the createdMessage
. If an error is received, it is emitted through theMessageCreateMono
. - See Also:
-
type
Requests to trigger the typing indicator in this channel. A single invocation of this method will trigger the indicator for 10 seconds or until the bot sends a message in this channel.- Returns:
- A
Mono
which completes upon successful triggering of the typing indicator in this channel. If an error is received, it is emitted through theMono
.
-
typeUntil
Requests to trigger the typing indicator in this channel. It will be continuously triggered every 10 seconds until the given publisher emits.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"))
- Parameters:
until
- The companionPublisher
that signals when to stop triggering the typing indicator.- Returns:
- A
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 theFlux
. - Implementation Note:
- The default implementation actually sends a typing request every 8 seconds so it appears continuous.
-
getMessagesBefore
Requests to retrieve all messages before the specified ID.The returned
Flux
will emit items in reverse-chronological order (newest to oldest). It is recommended to limit the emitted items by invoking eitherFlux.takeWhile(Predicate)
(to retrieve IDs within a specified range) orFlux.take(long)
(to retrieve a specific amount of IDs).The following example will get all messages from
messageId
tomyOtherMessageId
:getMessagesBefore(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) >= 0)
- Parameters:
messageId
- The ID of the newest message to retrieve. UseSnowflake.of(Instant)
to retrieve a time-based ID.- Returns:
- A
Flux
that continually emits allmessages
before the specified ID. If an error is received, it is emitted through theFlux
.
-
getMessagesAfter
Requests to retrieve all messages after the specified ID.The returned
Flux
will emit items in chronological order (oldest to newest). It is recommended to limit the emitted items by invoking eitherFlux.takeWhile(Predicate)
(to retrieve IDs within a specified range) orFlux.take(long)
(to retrieve a specific amount of IDs).The following example will get all messages from
messageId
tomyOtherMessageId
:getMessagesAfter(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) <= 0)
- Parameters:
messageId
- The ID of the oldest message to retrieve. UseSnowflake.of(Instant)
to retrieve a time-based ID.- Returns:
- A
Flux
that continually emits allmessages
after the specified ID. If an error is received, it is emitted through theFlux
.
-
getMessageById
Requests to retrieve the message as represented by the supplied ID. -
getMessageById
Requests to retrieve the message as represented by the supplied ID, using the given retrieval strategy. -
getPinnedMessages
Requests to retrieve all the pinned messages for this channel.- Returns:
- A
Flux
that continually emits all the pinned messages for this channel. If an error is received, it is emitted through theFlux
.
-
createMessage(EmbedCreateSpec...)
.