Class BotUtils


  • public class BotUtils
    extends Object
    Contains various utility methods.
    • Method Detail

      • splitMessage

        public static List<String> splitMessage​(String superLongMessage,
                                                int maxCharacters)
        Splits a message into several chunks which size is specified. If the chunk ends while the text is inside a codeblock or a blockquote, proper markdown is added to make the message continuous across chunks. This does not apply to inline markdown such as bold, italic or spoilers.
        Parameters:
        superLongMessage - the message to split
        maxCharacters - the max characters that a single chunk may have
        Returns:
        a List which elements are the chunks in the correct order
      • splitMessage

        public static List<String> splitMessage​(String superLongMessage)
        Splits a message into several chunks. Each chunk can have a max size of Message.MAX_CONTENT_LENGTH - 10.
        Parameters:
        superLongMessage - the message to split
        Returns:
        a List which elements are the chunks in the correct order
      • formatDuration

        public static String formatDuration​(Duration time)
        Formats a Duration into a human readable String.
        Parameters:
        time - the duration to format
        Returns:
        the formatted duration
      • sendPaginatedMessage

        public static reactor.core.publisher.Mono<Void> sendPaginatedMessage​(Context ctx,
                                                                             String text)
      • logCommandError

        public static reactor.core.publisher.Mono<Void> logCommandError​(reactor.util.Logger logger,
                                                                        Context ctx,
                                                                        Throwable e)