Class BotUtils
- java.lang.Object
-
- com.github.alex1304.ultimategdbot.api.utils.BotUtils
-
public class BotUtils extends Object
Contains various utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<String>chunkMessage(String superLongMessage)Splits a message into several chunks.static List<String>chunkMessage(String superLongMessage, int maxCharacters)Splits a message into several chunks which size is specified.static reactor.core.publisher.Mono<discord4j.core.object.entity.User>convertStringToUser(Bot bot, String str)static StringescapeMarkdown(String text)Escapes characters used in Markdown syntax using a backslashstatic StringformatDiscordUsername(discord4j.core.object.entity.User user)Formats the username of the user specified as argument with the format username#discriminatorstatic StringformatTimeMillis(java.time.Duration time)static reactor.core.publisher.Mono<String>generateDefaultDocumentation(Command cmd, Context ctx, String cmdName)Generates a default documentation for the command in a String format.static PropertiesgetGitPropertiesForPlugin(Plugin plugin)static StringjoinAliases(Set<String> aliases)static List<String>parseArgs(String input)static List<String>parseArgs(String input, String prefix)static StringremoveQuotesUnlessEscaped(String text)Returns the same test but without quotes, unless they are escaped with a backslash.static reactor.core.publisher.Flux<discord4j.core.object.entity.Message>sendMultipleMessagesToOneChannel(reactor.core.publisher.Mono<discord4j.core.object.entity.Channel> channel, Iterable<java.util.function.Consumer<discord4j.core.spec.MessageCreateSpec>> specs)static reactor.core.publisher.Flux<discord4j.core.object.entity.Message>sendMultipleSimpleMessagesToOneChannel(reactor.core.publisher.Mono<discord4j.core.object.entity.Channel> channel, Iterable<String> strings)static reactor.core.publisher.Flux<discord4j.core.object.entity.Message>sendOneMessageToMultipleChannels(reactor.core.publisher.Flux<discord4j.core.object.entity.Channel> channels, java.util.function.Consumer<discord4j.core.spec.MessageCreateSpec> spec)
-
-
-
Method Detail
-
generateDefaultDocumentation
public static reactor.core.publisher.Mono<String> generateDefaultDocumentation(Command cmd, Context ctx, String cmdName)
Generates a default documentation for the command in a String format.- Parameters:
cmd- the command to generate the doc forctx- the context to generate a more specific documentation according to the user permissions etccmdName- the alias that should be used for the command name- Returns:
- the documentation
-
chunkMessage
public static List<String> chunkMessage(String superLongMessage, int maxCharacters)
Splits a message into several chunks which size is specified.- 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
-
chunkMessage
public static List<String> chunkMessage(String superLongMessage)
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
-
sendMultipleMessagesToOneChannel
public static reactor.core.publisher.Flux<discord4j.core.object.entity.Message> sendMultipleMessagesToOneChannel(reactor.core.publisher.Mono<discord4j.core.object.entity.Channel> channel, Iterable<java.util.function.Consumer<discord4j.core.spec.MessageCreateSpec>> specs)
-
sendMultipleSimpleMessagesToOneChannel
public static reactor.core.publisher.Flux<discord4j.core.object.entity.Message> sendMultipleSimpleMessagesToOneChannel(reactor.core.publisher.Mono<discord4j.core.object.entity.Channel> channel, Iterable<String> strings)
-
sendOneMessageToMultipleChannels
public static reactor.core.publisher.Flux<discord4j.core.object.entity.Message> sendOneMessageToMultipleChannels(reactor.core.publisher.Flux<discord4j.core.object.entity.Channel> channels, java.util.function.Consumer<discord4j.core.spec.MessageCreateSpec> spec)
-
removeQuotesUnlessEscaped
public static String removeQuotesUnlessEscaped(String text)
Returns the same test but without quotes, unless they are escaped with a backslash.- Parameters:
text- the text- Returns:
- the same text but without unescaped quotes
-
escapeMarkdown
public static String escapeMarkdown(String text)
Escapes characters used in Markdown syntax using a backslash- Parameters:
text- the Markdown text to escape- Returns:
- String
-
formatDiscordUsername
public static String formatDiscordUsername(discord4j.core.object.entity.User user)
Formats the username of the user specified as argument with the format username#discriminator- Parameters:
user- The user whom username will be formatted- Returns:
- The formatted username as String.
-
convertStringToUser
public static reactor.core.publisher.Mono<discord4j.core.object.entity.User> convertStringToUser(Bot bot, String str)
-
formatTimeMillis
public static String formatTimeMillis(java.time.Duration time)
-
getGitPropertiesForPlugin
public static Properties getGitPropertiesForPlugin(Plugin plugin)
-
-