MutableCommandBuilder

class MutableCommandBuilder<C : Any>(commandBuilder: Command.Builder<C>, commandManager: CommandManager<C>)

A mutable Command.Builder wrapper, providing functions to assist in creating commands using the Kotlin builder DSL style

Constructors

Link copied to clipboard
constructor(name: String, description: Description = Description.empty(), aliases: Array<String> = emptyArray(), commandManager: CommandManager<C>)
constructor(name: String, description: Description = Description.empty(), aliases: Array<String> = emptyArray(), commandManager: CommandManager<C>, lambda: MutableCommandBuilder<C>.() -> Unit)

Create a new MutableCommandBuilder and invoke the provided receiver lambda on it

constructor(commandBuilder: Command.Builder<C>, commandManager: CommandManager<C>)

Properties

Link copied to clipboard
var commandBuilder: Command.Builder<C>

The command builder that is being mutated by this MutableCommandBuilder instance.

Link copied to clipboard
var commandDescription: CommandDescription

Field to get and set the command description for this command builder

Link copied to clipboard
var commandPermission: Permission

Field to get and set the required permission for this command builder

Link copied to clipboard

Field to get and set the required permission for this command builder

Link copied to clipboard
var senderType: TypeToken<out C>?

Field to get and set the required sender type for this command builder

Functions

Link copied to clipboard
fun appendHandler(handler: CommandExecutionHandler<C>): MutableCommandBuilder<C>

Sets a new command execution handler that invokes the given {@code handler} after the current {@link #handler() handler}.

Link copied to clipboard
fun argument(componentSupplier: () -> CommandComponent<C>): MutableCommandBuilder<C>

Add a new argument to this command

fun <T> argument(component: CommandComponent.Builder<C, T>): MutableCommandBuilder<C>
fun argument(component: CommandComponent<C>): MutableCommandBuilder<C>

Adds a new component to this command

Link copied to clipboard
fun build(): Command<C>

Build a Command from the current state of this builder

fun build(lambda: MutableCommandBuilder<C>.() -> Unit): Command<C>

Invoke the provided receiver lambda on this builder, then build a Command from the resulting state

Link copied to clipboard
fun commandDescription(commandDescription: CommandDescription): MutableCommandBuilder<C>

Sets the command description meta for this command

Link copied to clipboard

Make a new copy of this MutableCommandBuilder

Make a new copy of this MutableCommandBuilder and invoke the provided receiver lambda on it

fun copy(literal: String, description: Description, lambda: MutableCommandBuilder<C>.() -> Unit): MutableCommandBuilder<C>

Make a new copy of this MutableCommandBuilder, append a literal, and invoke the provided receiver lambda on it

Link copied to clipboard
fun flag(name: String, aliases: Array<String> = emptyArray(), description: Description = Description.empty()): MutableCommandBuilder<C>

Add a new presence flag component to this command

fun <T> flag(name: String, aliases: Array<String> = emptyArray(), description: Description = Description.empty(), builderModifier: CommandFlag.Builder<C, Void>.() -> CommandFlag.Builder<C, T>): MutableCommandBuilder<C>
fun <T> flag(name: String, aliases: Array<String> = emptyArray(), description: Description = Description.empty(), componentBuilder: CommandComponent.Builder<C, T>): MutableCommandBuilder<C>
fun <T> flag(name: String, aliases: Array<String> = emptyArray(), description: Description = Description.empty(), component: TypedCommandComponent<C, T>): MutableCommandBuilder<C>
fun <T> flag(name: String, aliases: Array<String> = emptyArray(), description: Description = Description.empty(), parser: ParserDescriptor<C, T>): MutableCommandBuilder<C>

Add a new flag component to this command

Link copied to clipboard
fun futureHandler(handler: CommandExecutionHandler.FutureCommandExecutionHandler<C>): MutableCommandBuilder<C>

Set the CommandExecutionHandler for this builder

Link copied to clipboard
fun handler(handler: CommandExecutionHandler<C>): MutableCommandBuilder<C>

Set the CommandExecutionHandler for this builder

Link copied to clipboard
fun literal(name: String, description: Description = Description.empty(), vararg aliases: String): MutableCommandBuilder<C>

Add a new literal argument to this command

Link copied to clipboard
fun <T : Any> meta(key: CloudKey<T>, value: T): MutableCommandBuilder<C>

Set the value for a certain CloudKey in the command meta storage for this builder

Link copied to clipboard
fun mutate(mutator: (Command.Builder<C>) -> Command.Builder<C>): MutableCommandBuilder<C>

Modify this MutableCommandBuilder's internal Command.Builder with a unary function

Link copied to clipboard
fun optional(componentSupplier: () -> CommandComponent.Builder<C, *>): MutableCommandBuilder<C>

Add a new argument to this command

fun optional(component: CommandComponent.Builder<C, *>): MutableCommandBuilder<C>
fun <T> optional(name: String, parser: ParserDescriptor<C, T>, mutator: CommandComponent.Builder<C, T>.() -> Unit = {}): MutableCommandBuilder<C>
fun <T> optional(name: CloudKey<T>, parser: ParserDescriptor<C, T>, mutator: CommandComponent.Builder<C, T>.() -> Unit = {}): MutableCommandBuilder<C>

Adds a new component to this command

Link copied to clipboard
fun permission(permission: Permission): MutableCommandBuilder<C>

Specify a permission required to execute this command

Link copied to clipboard
fun prependHandler(handler: CommandExecutionHandler<C>): MutableCommandBuilder<C>

Sets a new command execution handler that invokes the given {@code handler} before the current {@link #handler() handler}.

Link copied to clipboard

Build and register this command with the owning command manager

Link copied to clipboard

Create a new copy of this mutable builder, act on it with a receiver lambda, and then register it with the owning command manager

fun registerCopy(literal: String, description: Description, lambda: MutableCommandBuilder<C>.() -> Unit): MutableCommandBuilder<C>

Create a new copy of this mutable builder, append a literal, act on it with a receiver lambda, and then register it with the owning command manager

Link copied to clipboard
fun <T> required(componentSupplier: () -> CommandComponent.Builder<C, T>): MutableCommandBuilder<C>

Add a new argument to this command

fun required(component: CommandComponent.Builder<C, *>): MutableCommandBuilder<C>
fun <T> required(name: String, parser: ParserDescriptor<C, T>, mutator: CommandComponent.Builder<C, T>.() -> Unit = {}): MutableCommandBuilder<C>
fun <T> required(name: CloudKey<T>, parser: ParserDescriptor<C, T>, mutator: CommandComponent.Builder<C, T>.() -> Unit = {}): MutableCommandBuilder<C>

Adds a new component to this command

Link copied to clipboard
inline fun <T : C> senderType(): MutableCommandBuilder<C>

Specify a required sender type

Link copied to clipboard
infix fun <T : Any> CloudKey<T>.to(value: T): MutableCommandBuilder<C>

Set the value for a certain CloudKey in the command meta storage for this builder