Interface MessageChannel
-
- All Superinterfaces:
Channel,DiscordObject,Entity
- All Known Subinterfaces:
GuildMessageChannel,TopLevelGuildMessageChannel
- All Known Implementing Classes:
NewsChannel,PrivateChannel,TextChannel,VoiceChannel
public interface MessageChannel extends Channel
A Discord channel that can utilize messages.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface discord4j.core.object.entity.channel.Channel
Channel.Type
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default discord4j.core.spec.MessageCreateMonocreateEmbed(discord4j.core.spec.EmbedCreateSpec embed)Deprecated.default Mono<Message>createEmbed(Consumer<? super LegacyEmbedCreateSpec> spec)Deprecated.usecreateEmbed(EmbedCreateSpec)which offers an immutable approach to build specsdefault discord4j.core.spec.MessageCreateMonocreateMessage(discord4j.core.spec.EmbedCreateSpec... embeds)Requests to create a message with embeds.Mono<Message>createMessage(discord4j.core.spec.MessageCreateSpec spec)Requests to create a message.default discord4j.core.spec.MessageCreateMonocreateMessage(String message)Requests to create a message with a content.Mono<Message>createMessage(Consumer<? super LegacyMessageCreateSpec> spec)Deprecated.usecreateMessage(MessageCreateSpec)orcreateMessage(String)which offer an immutable approach to build specsMono<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.-
Methods inherited from interface discord4j.core.object.entity.channel.Channel
delete, delete, getMention, getRestChannel, getType
-
Methods inherited from interface discord4j.core.object.DiscordObject
getClient
-
-
-
-
Method Detail
-
getLastMessageId
Optional<Snowflake> 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
Mono<Message> getLastMessage()
Requests to retrieve the last message sent in this channel, if present.
-
getLastMessage
Mono<Message> getLastMessage(EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the last message sent in this channel, if present, using the given retrieval strategy.
-
getLastPinTimestamp
Optional<Instant> getLastPinTimestamp()
Gets when the last pinned message was pinned, if present.- Returns:
- When the last pinned message was pinned, if present.
-
createMessage
@Deprecated Mono<Message> createMessage(Consumer<? super LegacyMessageCreateSpec> spec)
Deprecated.usecreateMessage(MessageCreateSpec)orcreateMessage(String)which offer an immutable approach to build specsRequests to create a message.- Parameters:
spec- AConsumerthat provides a "blank"LegacyMessageCreateSpecto be operated on.- Returns:
- A
Monowhere, upon successful completion, emits the createdMessage. If an error is received, it is emitted through theMono.
-
createMessage
Mono<Message> createMessage(discord4j.core.spec.MessageCreateSpec spec)
Requests to create a message.
-
createMessage
default discord4j.core.spec.MessageCreateMono createMessage(String message)
Requests to create a message with a content. Other properties specifying how to create the message can be set via thewithXxxmethods of the returnedMessageCreateMono.- Parameters:
message- A string message to populate the message with.- Returns:
- A
MessageCreateMonowhere, upon successful completion, emits the createdMessage. If an error is received, it is emitted through theMessageCreateMono. - See Also:
createMessage(MessageCreateSpec)
-
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 thewithXxxmethods of the returnedMessageCreateMono.- Parameters:
embeds- immutable objects that specify how to create the embeds- Returns:
- A
MessageCreateMonowhere, upon successful completion, emits the createdMessage. If an error is received, it is emitted through theMessageCreateMono. - See Also:
createMessage(MessageCreateSpec)
-
createEmbed
@Deprecated default Mono<Message> createEmbed(Consumer<? super LegacyEmbedCreateSpec> spec)
Deprecated.usecreateEmbed(EmbedCreateSpec)which offers an immutable approach to build specsRequests to create a message with an embed.- Parameters:
spec- AConsumerthat provides a "blank"LegacyEmbedCreateSpecto be operated on.- Returns:
- A
Monowhere, 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 thewithXxxmethods of the returnedMessageCreateMono.- Parameters:
embed- an immutable object that specifies how to create the embed- Returns:
- A
MessageCreateMonowhere, upon successful completion, emits the createdMessage. If an error is received, it is emitted through theMessageCreateMono. - See Also:
createMessage(MessageCreateSpec)
-
type
Mono<Void> 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
Monowhich completes upon successful triggering of the typing indicator in this channel. If an error is received, it is emitted through theMono.
-
typeUntil
Flux<Long> typeUntil(Publisher<?> until)
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 companionPublisherthat signals when to stop triggering the typing indicator.- Returns:
- A
Fluxwhich 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
Flux<Message> getMessagesBefore(Snowflake messageId)
Requests to retrieve all messages before the specified ID.The returned
Fluxwill 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
messageIdtomyOtherMessageId: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
Fluxthat continually emits allmessagesbefore the specified ID. If an error is received, it is emitted through theFlux.
-
getMessagesAfter
Flux<Message> getMessagesAfter(Snowflake messageId)
Requests to retrieve all messages after the specified ID.The returned
Fluxwill 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
messageIdtomyOtherMessageId: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
Fluxthat continually emits allmessagesafter the specified ID. If an error is received, it is emitted through theFlux.
-
getMessageById
Mono<Message> getMessageById(Snowflake id)
Requests to retrieve the message as represented by the supplied ID.
-
getMessageById
Mono<Message> getMessageById(Snowflake id, EntityRetrievalStrategy retrievalStrategy)
Requests to retrieve the message as represented by the supplied ID, using the given retrieval strategy.
-
-