Class PrivateChannel

    • Constructor Detail

      • PrivateChannel

        public PrivateChannel​(GatewayDiscordClient gateway,
                              discord4j.discordjson.json.ChannelData data)
        Constructs an PrivateChannel with an associated GatewayDiscordClient and Discord data.
        Parameters:
        gateway - The GatewayDiscordClient associated to this object, must be non-null.
        data - The raw data as represented by Discord, must be non-null.
    • Method Detail

      • getRecipientIds

        public Set<Snowflake> getRecipientIds()
        Gets the IDs of the recipients for this private channel.
        Returns:
        The IDs of the recipients for this private channel.
      • getRecipients

        public Set<User> getRecipients()
        Gets the recipients for this private channel.
        Returns:
        The recipients for this private channel.
      • toString

        public String toString()
      • getLastMessageId

        public final Optional<Snowflake> getLastMessageId()
        Description copied from interface: MessageChannel
        Gets the ID of the last message sent in this channel, if present.
        Specified by:
        getLastMessageId in interface MessageChannel
        Returns:
        The ID of the last message sent in this channel, if present.
      • getLastMessage

        public final Mono<Message> getLastMessage()
        Description copied from interface: MessageChannel
        Requests to retrieve the last message sent in this channel, if present.
        Specified by:
        getLastMessage in interface MessageChannel
        Returns:
        A 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.
      • getLastMessage

        public Mono<Message> getLastMessage​(EntityRetrievalStrategy retrievalStrategy)
        Description copied from interface: MessageChannel
        Requests to retrieve the last message sent in this channel, if present, using the given retrieval strategy.
        Specified by:
        getLastMessage in interface MessageChannel
        Parameters:
        retrievalStrategy - the strategy to use to get the last message
        Returns:
        A 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.
      • getLastPinTimestamp

        public final Optional<Instant> getLastPinTimestamp()
        Description copied from interface: MessageChannel
        Gets when the last pinned message was pinned, if present.
        Specified by:
        getLastPinTimestamp in interface MessageChannel
        Returns:
        When the last pinned message was pinned, if present.
      • createMessage

        public Mono<Message> createMessage​(discord4j.core.spec.MessageCreateSpec spec)
        Description copied from interface: MessageChannel
        Requests to create a message.
        Specified by:
        createMessage in interface MessageChannel
        Parameters:
        spec - an immutable object that specifies how to create the message
        Returns:
        A Mono where, upon successful completion, emits the created Message. If an error is received, it is emitted through the Mono.
        See Also:
        MessageCreateSpec.builder()
      • type

        public final Mono<Void> type()
        Description copied from interface: MessageChannel
        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.
        Specified by:
        type in interface MessageChannel
        Returns:
        A Mono which completes upon successful triggering of the typing indicator in this channel. If an error is received, it is emitted through the Mono.
      • typeUntil

        public final Flux<Long> typeUntil​(Publisher<?> until)
        Description copied from interface: MessageChannel
        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"))
         
         
        Specified by:
        typeUntil in interface MessageChannel
        Parameters:
        until - The companion Publisher 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 the Flux.
      • getMessagesBefore

        public final Flux<Message> getMessagesBefore​(Snowflake messageId)
        Description copied from interface: MessageChannel
        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 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)

        Specified by:
        getMessagesBefore in interface MessageChannel
        Parameters:
        messageId - The ID of the newest message to retrieve. Use Snowflake.of(Instant) to retrieve a time-based ID.
        Returns:
        A Flux that continually emits all messages before the specified ID. If an error is received, it is emitted through the Flux.
      • getMessagesAfter

        public final Flux<Message> getMessagesAfter​(Snowflake messageId)
        Description copied from interface: MessageChannel
        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 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)

        Specified by:
        getMessagesAfter in interface MessageChannel
        Parameters:
        messageId - The ID of the oldest message to retrieve. Use Snowflake.of(Instant) to retrieve a time-based ID.
        Returns:
        A Flux that continually emits all messages after the specified ID. If an error is received, it is emitted through the Flux.
      • getMessageById

        public final Mono<Message> getMessageById​(Snowflake id)
        Description copied from interface: MessageChannel
        Requests to retrieve the message as represented by the supplied ID.
        Specified by:
        getMessageById in interface MessageChannel
        Parameters:
        id - The ID of the message.
        Returns:
        A 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.
      • getMessageById

        public Mono<Message> getMessageById​(Snowflake id,
                                            EntityRetrievalStrategy retrievalStrategy)
        Description copied from interface: MessageChannel
        Requests to retrieve the message as represented by the supplied ID, using the given retrieval strategy.
        Specified by:
        getMessageById in interface MessageChannel
        Parameters:
        id - The ID of the message.
        retrievalStrategy - the strategy to use to get the message
        Returns:
        A 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.
      • getPinnedMessages

        public final Flux<Message> getPinnedMessages()
        Description copied from interface: MessageChannel
        Requests to retrieve all the pinned messages for this channel.
        Specified by:
        getPinnedMessages in interface MessageChannel
        Returns:
        A Flux that continually emits all the pinned messages for this channel. If an error is received, it is emitted through the Flux.
      • getId

        public final Snowflake getId()
        Description copied from interface: Entity
        Gets the Snowflake that uniquely identifies this entity.
        Specified by:
        getId in interface Entity
        Returns:
        The Snowflake that uniquely identifies this entity.
      • getType

        public final Channel.Type getType()
        Description copied from interface: Channel
        Gets the type of channel.
        Specified by:
        getType in interface Channel
        Returns:
        The type of channel.
      • delete

        public final Mono<Void> delete​(@Nullable
                                       String reason)
        Description copied from interface: Channel
        Requests to delete this channel while optionally specifying a reason.
        Specified by:
        delete in interface Channel
        Parameters:
        reason - The reason, if present.
        Returns:
        A Mono where, upon successful completion, emits nothing; indicating the channel has been deleted. If an error is received, it is emitted through the Mono.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object