Class BotUtils

java.lang.Object
com.github.alex1304.ultimategdbot.api.utils.BotUtils

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

    • 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
    • debugError

      public static reactor.core.publisher.Flux<discord4j.core.object.entity.Message> debugError​(String header, Context ctx, Throwable error)
      Sends an error report to the debug log channel.
      Parameters:
      header - the first sentence to write on the report
      ctx - the context of the error
      error - the error itself
      Returns:
      a Flux of messages that were sent in the debug log channel. If the error report exceeds Message.MAX_CONTENT_LENGTH characters, it will be split using splitMessage(String), in this case the Flux may emit more than one message instance.
    • sendPaginatedMessage

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

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

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