Class MessageSetImpl

    • Constructor Detail

      • MessageSetImpl

        public MessageSetImpl​(NavigableSet<Message> messages)
        Creates a new message set.
        Parameters:
        messages - The messages to be contained in this set.
      • MessageSetImpl

        public MessageSetImpl​(Collection<Message> messages)
        Creates a new message set.
        Parameters:
        messages - The messages to be contained in this set.
      • MessageSetImpl

        public MessageSetImpl​(Message... messages)
        Creates a new message set.
        Parameters:
        messages - The messages to be contained in this set.
    • Method Detail

      • getMessagesUntil

        public static CompletableFuture<MessageSet> getMessagesUntil​(TextChannel channel,
                                                                     Predicate<Message> condition)
        Gets messages in the given channel from the newer end until one that meets the given condition is found. If no message matches the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The abort condition for when to stop retrieving messages.
        Returns:
        The messages.
        See Also:
        getMessagesAsStream(TextChannel)
      • getMessagesWhile

        public static CompletableFuture<MessageSet> getMessagesWhile​(TextChannel channel,
                                                                     Predicate<Message> condition)
        Gets messages in the given channel from the newer end while they meet the given condition. If the first message does not match the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The condition that has to be met.
        Returns:
        The messages.
        See Also:
        getMessagesAsStream(TextChannel)
      • getMessagesAsStream

        public static Stream<Message> getMessagesAsStream​(TextChannel channel)
        Gets a stream of messages in the given channel sorted from newest to oldest.

        The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.

        Parameters:
        channel - The channel of the messages.
        Returns:
        The stream.
        See Also:
        getMessages(TextChannel, int)
      • getMessagesBefore

        public static CompletableFuture<MessageSet> getMessagesBefore​(TextChannel channel,
                                                                      int limit,
                                                                      long before)
        Gets up to a given amount of messages in the given channel before a given message in any channel.
        Parameters:
        channel - The channel of the messages.
        limit - The limit of messages to get.
        before - Get messages before the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesBeforeAsStream(TextChannel, long)
      • getMessagesBeforeUntil

        public static CompletableFuture<MessageSet> getMessagesBeforeUntil​(TextChannel channel,
                                                                           Predicate<Message> condition,
                                                                           long before)
        Gets messages in the given channel before a given message in any channel until one that meets the given condition is found. If no message matches the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The abort condition for when to stop retrieving messages.
        before - Get messages before the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesBeforeAsStream(TextChannel, long)
      • getMessagesBeforeWhile

        public static CompletableFuture<MessageSet> getMessagesBeforeWhile​(TextChannel channel,
                                                                           Predicate<Message> condition,
                                                                           long before)
        Gets messages in the given channel before a given message in any channel while they meet the given condition. If the first message does not match the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The condition that has to be met.
        before - Get messages before the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesBeforeAsStream(TextChannel, long)
      • getMessagesBeforeAsStream

        public static Stream<Message> getMessagesBeforeAsStream​(TextChannel channel,
                                                                long before)
        Gets a stream of messages in the given channel before a given message in any channel sorted from newest to oldest.

        The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.

        Parameters:
        channel - The channel of the messages.
        before - Get messages before the message with this id.
        Returns:
        The stream.
        See Also:
        getMessagesBefore(TextChannel, int, long)
      • getMessagesAfter

        public static CompletableFuture<MessageSet> getMessagesAfter​(TextChannel channel,
                                                                     int limit,
                                                                     long after)
        Gets up to a given amount of messages in the given channel after a given message in any channel.
        Parameters:
        channel - The channel of the messages.
        limit - The limit of messages to get.
        after - Get messages after the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesAfterAsStream(TextChannel, long)
      • getMessagesAfterUntil

        public static CompletableFuture<MessageSet> getMessagesAfterUntil​(TextChannel channel,
                                                                          Predicate<Message> condition,
                                                                          long after)
        Gets messages in the given channel after a given message in any channel until one that meets the given condition is found. If no message matches the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The abort condition for when to stop retrieving messages.
        after - Get messages after the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesAfterAsStream(TextChannel, long)
      • getMessagesAfterWhile

        public static CompletableFuture<MessageSet> getMessagesAfterWhile​(TextChannel channel,
                                                                          Predicate<Message> condition,
                                                                          long after)
        Gets messages in the given channel after a given message in any channel while they meet the given condition. If the first message does not match the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The condition that has to be met.
        after - Get messages after the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesAfterAsStream(TextChannel, long)
      • getMessagesAfterAsStream

        public static Stream<Message> getMessagesAfterAsStream​(TextChannel channel,
                                                               long after)
        Gets a stream of messages in the given channel after a given message in any channel sorted from oldest to newest.

        The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.

        Parameters:
        channel - The channel of the messages.
        after - Get messages after the message with this id.
        Returns:
        The stream.
        See Also:
        getMessagesAfter(TextChannel, int, long)
      • getMessagesAround

        public static CompletableFuture<MessageSet> getMessagesAround​(TextChannel channel,
                                                                      int limit,
                                                                      long around)
        Gets up to a given amount of messages in the given channel around a given message in any channel. The given message will be part of the result in addition to the messages around if it was sent in the given channel and does not count towards the limit. Half of the messages will be older than the given message and half of the messages will be newer. If there aren't enough older or newer messages, the actual amount of messages will be less than the given limit. It's also not guaranteed to be perfectly balanced.
        Parameters:
        channel - The channel of the messages.
        limit - The limit of messages to get.
        around - Get messages around the message with this id.
        Returns:
        The messages.
        See Also:
        getMessagesAroundAsStream(TextChannel, long)
      • getMessagesAroundUntil

        public static CompletableFuture<MessageSet> getMessagesAroundUntil​(TextChannel channel,
                                                                           Predicate<Message> condition,
                                                                           long around)
        Gets messages in the given channel around a given message in any channel until one that meets the given condition is found. If no message matches the condition, an empty set is returned. The given message will be part of the result in addition to the messages around if it was sent in the given channel and is matched against the condition and will abort retrieval. Half of the messages will be older than the given message and half of the messages will be newer. If there aren't enough older or newer messages, the halves will not be same-sized. It's also not guaranteed to be perfectly balanced.
        Parameters:
        channel - The channel of the messages.
        condition - The abort condition for when to stop retrieving messages.
        around - Get messages around the message with this id.
        Returns:
        The messages.
      • getMessagesAroundWhile

        public static CompletableFuture<MessageSet> getMessagesAroundWhile​(TextChannel channel,
                                                                           Predicate<Message> condition,
                                                                           long around)
        Gets messages in the given channel around a given message in any channel while they meet the given condition. If the first message does not match the condition, an empty set is returned. The given message will be part of the result in addition to the messages around if it was sent in the given channel and is matched against the condition and will abort retrieval. Half of the messages will be older than the given message and half of the messages will be newer. If there aren't enough older or newer messages, the halves will not be same-sized. It's also not guaranteed to be perfectly balanced.
        Parameters:
        channel - The channel of the messages.
        condition - The condition that has to be met.
        around - Get messages around the message with this id.
        Returns:
        The messages.
      • getMessagesAroundAsStream

        public static Stream<Message> getMessagesAroundAsStream​(TextChannel channel,
                                                                long around)
        Gets a stream of messages in the given channel around a given message in any channel. The first message in the stream will be the given message if it was sent in the given channel. After that you will always get an older message and a newer message alternating as long as on both sides messages are available. If only on one side further messages are available, only those are delivered further on. It's not guaranteed to be perfectly balanced.

        The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.

        Parameters:
        channel - The channel of the messages.
        around - Get messages around the message with this id.
        Returns:
        The stream.
        See Also:
        getMessagesAround(TextChannel, int, long)
      • getMessagesBetween

        public static CompletableFuture<MessageSet> getMessagesBetween​(TextChannel channel,
                                                                       long from,
                                                                       long to)
        Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries. Gets up to a given amount of messages in the given channel before a given message in any channel.
        Parameters:
        channel - The channel of the messages.
        from - The id of the start boundary messages.
        to - The id of the other boundary messages.
        Returns:
        The messages.
        See Also:
        getMessagesBetweenAsStream(TextChannel, long, long)
      • getMessagesBetweenUntil

        public static CompletableFuture<MessageSet> getMessagesBetweenUntil​(TextChannel channel,
                                                                            Predicate<Message> condition,
                                                                            long from,
                                                                            long to)
        Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, until one that meets the given condition is found. If no message matches the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The abort condition for when to stop retrieving messages.
        from - The id of the start boundary messages.
        to - The id of the other boundary messages.
        Returns:
        The messages.
        See Also:
        getMessagesBetweenAsStream(TextChannel, long, long)
      • getMessagesBetweenWhile

        public static CompletableFuture<MessageSet> getMessagesBetweenWhile​(TextChannel channel,
                                                                            Predicate<Message> condition,
                                                                            long from,
                                                                            long to)
        Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, while they meet the given condition. If the first message does not match the condition, an empty set is returned.
        Parameters:
        channel - The channel of the messages.
        condition - The condition that has to be met.
        from - The id of the start boundary messages.
        to - The id of the other boundary messages.
        Returns:
        The messages.
        See Also:
        getMessagesBetweenAsStream(TextChannel, long, long)
      • getMessagesBetweenAsStream

        public static Stream<Message> getMessagesBetweenAsStream​(TextChannel channel,
                                                                 long from,
                                                                 long to)
        Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, sorted from first given message to the second given message.

        The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.

        Parameters:
        channel - The channel of the messages.
        from - The id of the start boundary messages.
        to - The id of the other boundary messages.
        Returns:
        The stream.
        See Also:
        getMessagesBetween(TextChannel, long, long)