ArgumentCommandBuilder

class ArgumentCommandBuilder<Source : SharedSuggestionProvider, T>(name: String, typeProvider: (CommandBuildContext) -> ArgumentType<T>) : CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>> (source)

Constructors

Link copied to clipboard
constructor(name: String, typeProvider: (CommandBuildContext) -> ArgumentType<T>)

Functions

Link copied to clipboard
inline fun <T> argument(name: String, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. The ArgumentType will be resolved using the reified type T. For a list of supported types, have a look at ArgumentTypeUtils.fromReifiedType, as it is the function used by this builder function.

inline fun <T> argument(name: String, type: ArgumentType<T>, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. This variant of the argument function allows you to specify the ArgumentType in the classical Brigadier way.

@JvmName(name = "argumentWithCustomParser")
inline fun <T> argument(name: String, crossinline parser: (StringReader) -> T, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. This variant of the argument function you to specifiy the argument parse logic using a Kotlin lambda function (parser).

@JvmName(name = "argumentWithContextualType")
inline fun <T> argument(name: String, noinline typeProvider: (CommandBuildContext) -> ArgumentType<T>, builder: SimpleArgumentBuilder<Source, T> = {}): ArgumentCommandBuilder<Source, T>

Adds a new argument to this command. This variant of the argument function allows you to pass and argument which depends on the CommandBuildContext.

Link copied to clipboard
fun brigadier(block: RequiredArgumentBuilder<Source, T>.(context: CommandBuildContext) -> Unit): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

This function allows you to access the regular Brigadier builder. The type of this in its context will equal the type of Builder.

Link copied to clipboard
inline fun literal(name: String, builder: LiteralCommandBuilder<Source>.() -> Unit = {}): LiteralCommandBuilder<Source>

Adds a new subcommand / literal to this command.

Link copied to clipboard
fun requires(predicate: (source: Source) -> Boolean): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

Specifies that the given predicate must return true for the Source in order for it to be able to execute this part of the command tree. Use this function on the root command node to secure the whole command.

Link copied to clipboard
fun requiresPermissionLevel(level: Int): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

Specifies that the given permission level is required to execute this part of the command tree. A shortcut delegating to requires.

fun requiresPermissionLevel(level: PermissionLevel): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

Specifies that the PermissionLevel given as level is required to execute this part of the command tree. A shortcut delegating to requires.

Link copied to clipboard
infix inline fun runs(crossinline block: CommandContext<Source>.() -> Unit): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

Adds execution logic to this command. The place where this function is called matters, as this defines for which path in the command tree this executor should be called.

Link copied to clipboard
infix inline fun runsAsync(crossinline block: suspend CommandContext<Source>.() -> Unit): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

Does the same as runs (see its docs for more information), but launches the command logic in an async coroutine.

Link copied to clipboard
infix inline fun simpleExecutes(crossinline executor: CommandContext<Source>.() -> Unit): CommandBuilder<Source, RequiredArgumentBuilder<Source, T>, ArgumentCommandNode<Source, T>>

Adds custom execution logic to this command. DEPRECATED Use runs instead.

Link copied to clipboard
fun simpleSuggests(coroutineScope: CoroutineScope = silkCoroutineScope, suggestionBuilder: suspend (CommandContext<Source>) -> Iterable<Any?>?): ArgumentCommandBuilder<Source, T>

Adds custom suspending suggestion logic for an argument.

Link copied to clipboard
inline fun suggestList(crossinline suggestionsBuilder: (CommandContext<Source>) -> Iterable<Any?>?): ArgumentCommandBuilder<Source, T>

Suggest the entries of the iterable which is the result of the suggestionsBuilder.

Link copied to clipboard
inline fun suggestListSuspending(coroutineScope: CoroutineScope = silkCoroutineScope, crossinline suggestionsBuilder: suspend (CommandContext<Source>) -> Iterable<Any?>?): ArgumentCommandBuilder<Source, T>

Suggest the entries of the iterable which is the result of the suggestionsBuilder.

Link copied to clipboard
inline fun suggestListWithTooltips(crossinline suggestionsBuilder: (CommandContext<Source>) -> Iterable<Pair<Any?, Message>?>?): ArgumentCommandBuilder<Source, T>

Suggest the entries of the iterable which is the result of the suggestionsBuilder. Additionaly, a separate tooltip associated with each suggestion will be shown as well.

Link copied to clipboard
inline fun suggestListWithTooltipsSuspending(coroutineScope: CoroutineScope = silkCoroutineScope, crossinline suggestionsBuilder: (CommandContext<Source>) -> Iterable<Pair<Any?, Message>?>?): ArgumentCommandBuilder<Source, T>

Suggest the entries of the iterable which is the result of the suggestionsBuilder. Additionaly, a separate tooltip associated with each suggestion will be shown as well.

Link copied to clipboard
inline fun suggestSingle(crossinline suggestionBuilder: (CommandContext<Source>) -> Any?): ArgumentCommandBuilder<Source, T>

Suggest the value which is the result of the suggestionBuilder.

Link copied to clipboard
inline fun suggestSingleSuspending(coroutineScope: CoroutineScope = silkCoroutineScope, crossinline suggestionBuilder: suspend (CommandContext<Source>) -> Any?): ArgumentCommandBuilder<Source, T>

Suggest the value which is the result of the suggestionBuilder.

Link copied to clipboard
inline fun suggestSingleWithTooltip(crossinline suggestionBuilder: (CommandContext<Source>) -> Pair<Any, Message>?): ArgumentCommandBuilder<Source, T>

Suggest the value which is the result of the suggestionBuilder. Additionaly, a separate tooltip associated with the suggestion will be shown as well.

Link copied to clipboard
inline fun suggestSingleWithTooltipSuspending(coroutineScope: CoroutineScope = silkCoroutineScope, crossinline suggestionBuilder: suspend (CommandContext<Source>) -> Pair<Any?, Message>?): ArgumentCommandBuilder<Source, T>

Suggest the value which is the result of the suggestionBuilder. Additionaly, a separate tooltip associated with the suggestion will be shown as well.

Link copied to clipboard
open fun toBrigadier(context: CommandBuildContext): List<ArgumentCommandNode<Source, T>>

Converts this Kotlin command builder abstraction to an ArgumentBuilder of Brigadier.