Class BotUtils
java.lang.Object
com.github.alex1304.ultimategdbot.api.util.BotUtils
public class BotUtils extends Object
Contains various utility methods.
-
Method Summary
Modifier and Type Method Description static String
formatDuration(Duration time)
Formats a Duration into a human readable String.static reactor.core.publisher.Mono<Void>
logCommandError(reactor.util.Logger logger, Context ctx, Throwable e)
static reactor.core.publisher.Mono<Void>
sendPaginatedMessage(Context ctx, String text)
static reactor.core.publisher.Mono<Void>
sendPaginatedMessage(Context ctx, String text, PaginationControls controls)
static reactor.core.publisher.Mono<Void>
sendPaginatedMessage(Context ctx, String text, PaginationControls controls, int pageLength)
static List<String>
splitMessage(String superLongMessage)
Splits a message into several chunks.static List<String>
splitMessage(String superLongMessage, int maxCharacters)
Splits a message into several chunks which size is specified.
-
Method Details
-
splitMessage
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 splitmaxCharacters
- the max characters that a single chunk may have- Returns:
- a List which elements are the chunks in the correct order
-
splitMessage
Splits a message into several chunks. Each chunk can have a max size ofMessage.MAX_CONTENT_LENGTH
- 10.- Parameters:
superLongMessage
- the message to split- Returns:
- a List which elements are the chunks in the correct order
-
formatDuration
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, PaginationControls controls, int pageLength) -
sendPaginatedMessage
public static reactor.core.publisher.Mono<Void> sendPaginatedMessage(Context ctx, String text, PaginationControls controls) -
sendPaginatedMessage
-
logCommandError
-