Add helper method for flags to MutableCommandBuilder
This commit is contained in:
parent
47d602fde1
commit
39b94a3df0
1 changed files with 177 additions and 80 deletions
|
|
@ -53,10 +53,10 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
name: String,
|
name: String,
|
||||||
description: Description = Description.empty(),
|
description: Description = Description.empty(),
|
||||||
aliases: Array<String> = emptyArray(),
|
aliases: Array<String> = emptyArray(),
|
||||||
commandManager: CommandManager<C>
|
commandManager: CommandManager<C>
|
||||||
) {
|
) {
|
||||||
this.commandManager = commandManager
|
this.commandManager = commandManager
|
||||||
this.commandBuilder = commandManager.commandBuilder(name, description, *aliases)
|
this.commandBuilder = commandManager.commandBuilder(name, description, *aliases)
|
||||||
|
|
@ -73,18 +73,18 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
name: String,
|
name: String,
|
||||||
description: Description = Description.empty(),
|
description: Description = Description.empty(),
|
||||||
aliases: Array<String> = emptyArray(),
|
aliases: Array<String> = emptyArray(),
|
||||||
commandManager: CommandManager<C>,
|
commandManager: CommandManager<C>,
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
) : this(name, description, aliases, commandManager) {
|
) : this(name, description, aliases, commandManager) {
|
||||||
lambda(this)
|
lambda(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor(
|
private constructor(
|
||||||
commandManager: CommandManager<C>,
|
commandManager: CommandManager<C>,
|
||||||
commandBuilder: Command.Builder<C>
|
commandBuilder: Command.Builder<C>
|
||||||
) {
|
) {
|
||||||
this.commandManager = commandManager
|
this.commandManager = commandManager
|
||||||
this.commandBuilder = commandBuilder
|
this.commandBuilder = commandBuilder
|
||||||
|
|
@ -97,7 +97,7 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun build(): Command<C> =
|
public fun build(): Command<C> =
|
||||||
this.commandBuilder.build()
|
this.commandBuilder.build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke the provided receiver lambda on this builder, then build a [Command] from the resulting state
|
* Invoke the provided receiver lambda on this builder, then build a [Command] from the resulting state
|
||||||
|
|
@ -107,7 +107,7 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun build(
|
public fun build(
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): Command<C> {
|
): Command<C> {
|
||||||
lambda(this)
|
lambda(this)
|
||||||
return this.commandBuilder.build()
|
return this.commandBuilder.build()
|
||||||
|
|
@ -121,14 +121,14 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun mutate(
|
public fun mutate(
|
||||||
mutator: (Command.Builder<C>) -> Command.Builder<C>
|
mutator: (Command.Builder<C>) -> Command.Builder<C>
|
||||||
): MutableCommandBuilder<C> {
|
): MutableCommandBuilder<C> {
|
||||||
this.commandBuilder = mutator(this.commandBuilder)
|
this.commandBuilder = mutator(this.commandBuilder)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onlyMutate(
|
private fun onlyMutate(
|
||||||
mutator: (Command.Builder<C>) -> Command.Builder<C>
|
mutator: (Command.Builder<C>) -> Command.Builder<C>
|
||||||
): Unit {
|
): Unit {
|
||||||
mutate(mutator)
|
mutate(mutator)
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun copy(): MutableCommandBuilder<C> =
|
public fun copy(): MutableCommandBuilder<C> =
|
||||||
MutableCommandBuilder(this.commandManager, this.commandBuilder)
|
MutableCommandBuilder(this.commandManager, this.commandBuilder)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a new copy of this [MutableCommandBuilder] and invoke the provided receiver lambda on it
|
* Make a new copy of this [MutableCommandBuilder] and invoke the provided receiver lambda on it
|
||||||
|
|
@ -150,11 +150,11 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun copy(
|
public fun copy(
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
copy().apply {
|
copy().apply {
|
||||||
lambda(this)
|
lambda(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a new copy of this [MutableCommandBuilder], append a literal, and invoke the provided receiver lambda on it
|
* Make a new copy of this [MutableCommandBuilder], append a literal, and invoke the provided receiver lambda on it
|
||||||
|
|
@ -166,14 +166,14 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun copy(
|
public fun copy(
|
||||||
literal: String,
|
literal: String,
|
||||||
description: Description,
|
description: Description,
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
copy().apply {
|
copy().apply {
|
||||||
literal(literal, description)
|
literal(literal, description)
|
||||||
lambda(this)
|
lambda(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a new copy of this [MutableCommandBuilder], append a literal, and invoke the provided receiver lambda on it
|
* Make a new copy of this [MutableCommandBuilder], append a literal, and invoke the provided receiver lambda on it
|
||||||
|
|
@ -184,13 +184,13 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun copy(
|
public fun copy(
|
||||||
literal: String,
|
literal: String,
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
copy().apply {
|
copy().apply {
|
||||||
literal(literal)
|
literal(literal)
|
||||||
lambda(this)
|
lambda(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build and register this command with the owning command manager
|
* Build and register this command with the owning command manager
|
||||||
|
|
@ -200,9 +200,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun register(): MutableCommandBuilder<C> =
|
public fun register(): MutableCommandBuilder<C> =
|
||||||
apply {
|
apply {
|
||||||
this.commandManager.command(this)
|
this.commandManager.command(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new copy of this mutable builder, act on it with a receiver lambda, and then register it with the owning
|
* Create a new copy of this mutable builder, act on it with a receiver lambda, and then register it with the owning
|
||||||
|
|
@ -214,9 +214,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun registerCopy(
|
public fun registerCopy(
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
copy(lambda).register()
|
copy(lambda).register()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new copy of this mutable builder, append a literal, act on it with a receiver lambda, and then register it with
|
* Create a new copy of this mutable builder, append a literal, act on it with a receiver lambda, and then register it with
|
||||||
|
|
@ -230,10 +230,10 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun registerCopy(
|
public fun registerCopy(
|
||||||
literal: String,
|
literal: String,
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
copy(literal, lambda).register()
|
copy(literal, lambda).register()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new copy of this mutable builder, append a literal, act on it with a receiver lambda, and then register it with
|
* Create a new copy of this mutable builder, append a literal, act on it with a receiver lambda, and then register it with
|
||||||
|
|
@ -248,11 +248,11 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun registerCopy(
|
public fun registerCopy(
|
||||||
literal: String,
|
literal: String,
|
||||||
description: Description,
|
description: Description,
|
||||||
lambda: MutableCommandBuilder<C>.() -> Unit
|
lambda: MutableCommandBuilder<C>.() -> Unit
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
copy(literal, description, lambda).register()
|
copy(literal, description, lambda).register()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value for a certain [CommandMeta.Key] in the command meta storage for this builder
|
* Set the value for a certain [CommandMeta.Key] in the command meta storage for this builder
|
||||||
|
|
@ -264,10 +264,10 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun <T : Any> meta(
|
public fun <T : Any> meta(
|
||||||
key: CommandMeta.Key<T>,
|
key: CommandMeta.Key<T>,
|
||||||
value: T
|
value: T
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.meta(key, value) }
|
mutate { it.meta(key, value) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value for a certain [CommandMeta.Key] in the command meta storage for this builder
|
* Set the value for a certain [CommandMeta.Key] in the command meta storage for this builder
|
||||||
|
|
@ -278,9 +278,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public infix fun <T : Any> CommandMeta.Key<T>.to(
|
public infix fun <T : Any> CommandMeta.Key<T>.to(
|
||||||
value: T
|
value: T
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
meta(this, value)
|
meta(this, value)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the [CommandMeta.DESCRIPTION] meta for this command
|
* Set the [CommandMeta.DESCRIPTION] meta for this command
|
||||||
|
|
@ -290,9 +290,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun commandDescription(
|
public fun commandDescription(
|
||||||
description: String
|
description: String
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
meta(CommandMeta.DESCRIPTION, description)
|
meta(CommandMeta.DESCRIPTION, description)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the [CommandMeta.LONG_DESCRIPTION] meta for this command
|
* Set the [CommandMeta.LONG_DESCRIPTION] meta for this command
|
||||||
|
|
@ -302,9 +302,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun longCommandDescription(
|
public fun longCommandDescription(
|
||||||
description: String
|
description: String
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
meta(CommandMeta.LONG_DESCRIPTION, description)
|
meta(CommandMeta.LONG_DESCRIPTION, description)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the [CommandMeta.HIDDEN] meta for this command
|
* Set the [CommandMeta.HIDDEN] meta for this command
|
||||||
|
|
@ -314,9 +314,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun hidden(
|
public fun hidden(
|
||||||
hidden: Boolean = true
|
hidden: Boolean = true
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
meta(CommandMeta.HIDDEN, hidden)
|
meta(CommandMeta.HIDDEN, hidden)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a required sender type
|
* Specify a required sender type
|
||||||
|
|
@ -326,7 +326,7 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public inline fun <reified T : C> senderType(): MutableCommandBuilder<C> =
|
public inline fun <reified T : C> senderType(): MutableCommandBuilder<C> =
|
||||||
mutate { it.senderType(T::class) }
|
mutate { it.senderType(T::class) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a required sender type
|
* Specify a required sender type
|
||||||
|
|
@ -336,9 +336,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun senderType(
|
public fun senderType(
|
||||||
type: KClass<out C>
|
type: KClass<out C>
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.senderType(type) }
|
mutate { it.senderType(type) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field to get and set the required sender type for this command builder
|
* Field to get and set the required sender type for this command builder
|
||||||
|
|
@ -360,9 +360,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun senderType(
|
public fun senderType(
|
||||||
type: Class<out C>
|
type: Class<out C>
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.senderType(type) }
|
mutate { it.senderType(type) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a permission required to execute this command
|
* Specify a permission required to execute this command
|
||||||
|
|
@ -372,9 +372,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun permission(
|
public fun permission(
|
||||||
permission: String
|
permission: String
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.permission(permission) }
|
mutate { it.permission(permission) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a permission required to execute this command
|
* Specify a permission required to execute this command
|
||||||
|
|
@ -384,9 +384,9 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun permission(
|
public fun permission(
|
||||||
permission: CommandPermission
|
permission: CommandPermission
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.permission(permission) }
|
mutate { it.permission(permission) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field to get and set the required permission for this command builder
|
* Field to get and set the required permission for this command builder
|
||||||
|
|
@ -415,10 +415,10 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun argument(
|
public fun argument(
|
||||||
argument: CommandArgument<C, *>,
|
argument: CommandArgument<C, *>,
|
||||||
description: Description = Description.empty()
|
description: Description = Description.empty()
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.argument(argument, description) }
|
mutate { it.argument(argument, description) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new argument to this command
|
* Add a new argument to this command
|
||||||
|
|
@ -429,10 +429,10 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun argument(
|
public fun argument(
|
||||||
argument: CommandArgument.Builder<C, *>,
|
argument: CommandArgument.Builder<C, *>,
|
||||||
description: Description = Description.empty()
|
description: Description = Description.empty()
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.argument(argument, description) }
|
mutate { it.argument(argument, description) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new argument to this command
|
* Add a new argument to this command
|
||||||
|
|
@ -443,10 +443,10 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun argument(
|
public fun argument(
|
||||||
description: Description = Description.empty(),
|
description: Description = Description.empty(),
|
||||||
argumentSupplier: () -> CommandArgument<C, *>
|
argumentSupplier: () -> CommandArgument<C, *>
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.argument(argumentSupplier(), description) }
|
mutate { it.argument(argumentSupplier(), description) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new literal argument to this command
|
* Add a new literal argument to this command
|
||||||
|
|
@ -458,11 +458,11 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun literal(
|
public fun literal(
|
||||||
name: String,
|
name: String,
|
||||||
description: Description = Description.empty(),
|
description: Description = Description.empty(),
|
||||||
vararg aliases: String
|
vararg aliases: String
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.literal(name, description, *aliases) }
|
mutate { it.literal(name, description, *aliases) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the [CommandExecutionHandler] for this builder
|
* Set the [CommandExecutionHandler] for this builder
|
||||||
|
|
@ -472,7 +472,104 @@ public class MutableCommandBuilder<C : Any> {
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
public fun handler(
|
public fun handler(
|
||||||
handler: CommandExecutionHandler<C>
|
handler: CommandExecutionHandler<C>
|
||||||
): MutableCommandBuilder<C> =
|
): MutableCommandBuilder<C> =
|
||||||
mutate { it.handler(handler) }
|
mutate { it.handler(handler) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new flag argument to this command
|
||||||
|
*
|
||||||
|
* @param name name of the flag
|
||||||
|
* @param aliases flag aliases
|
||||||
|
* @param description description of the flag
|
||||||
|
* @param argumentSupplier argument supplier for the flag
|
||||||
|
* @return this mutable builder
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public fun flag(
|
||||||
|
name: String,
|
||||||
|
aliases: Array<String> = emptyArray(),
|
||||||
|
description: Description = Description.empty(),
|
||||||
|
argumentSupplier: () -> CommandArgument<C, *>
|
||||||
|
): MutableCommandBuilder<C> = mutate {
|
||||||
|
it.flag(
|
||||||
|
this.commandManager.flagBuilder(name)
|
||||||
|
.withAliases(*aliases)
|
||||||
|
.withDescription(description)
|
||||||
|
.withArgument(argumentSupplier())
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new flag argument to this command
|
||||||
|
*
|
||||||
|
* @param name name of the flag
|
||||||
|
* @param aliases flag aliases
|
||||||
|
* @param description description of the flag
|
||||||
|
* @param argument argument for the flag
|
||||||
|
* @return this mutable builder
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public fun flag(
|
||||||
|
name: String,
|
||||||
|
aliases: Array<String> = emptyArray(),
|
||||||
|
description: Description = Description.empty(),
|
||||||
|
argument: CommandArgument<C, *>
|
||||||
|
): MutableCommandBuilder<C> = mutate {
|
||||||
|
it.flag(
|
||||||
|
this.commandManager.flagBuilder(name)
|
||||||
|
.withAliases(*aliases)
|
||||||
|
.withDescription(description)
|
||||||
|
.withArgument(argument)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new flag argument to this command
|
||||||
|
*
|
||||||
|
* @param name name of the flag
|
||||||
|
* @param aliases flag aliases
|
||||||
|
* @param description description of the flag
|
||||||
|
* @param argumentBuilder command argument builder for the flag
|
||||||
|
* @return this mutable builder
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public fun flag(
|
||||||
|
name: String,
|
||||||
|
aliases: Array<String> = emptyArray(),
|
||||||
|
description: Description = Description.empty(),
|
||||||
|
argumentBuilder: CommandArgument.Builder<C, *>
|
||||||
|
): MutableCommandBuilder<C> = mutate {
|
||||||
|
it.flag(
|
||||||
|
this.commandManager.flagBuilder(name)
|
||||||
|
.withAliases(*aliases)
|
||||||
|
.withDescription(description)
|
||||||
|
.withArgument(argumentBuilder)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new presence flag argument to this command
|
||||||
|
*
|
||||||
|
* @param name name of the flag
|
||||||
|
* @param aliases flag aliases
|
||||||
|
* @param description description of the flag
|
||||||
|
* @return this mutable builder
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public fun flag(
|
||||||
|
name: String,
|
||||||
|
aliases: Array<String> = emptyArray(),
|
||||||
|
description: Description = Description.empty(),
|
||||||
|
): MutableCommandBuilder<C> = mutate {
|
||||||
|
it.flag(
|
||||||
|
this.commandManager.flagBuilder(name)
|
||||||
|
.withAliases(*aliases)
|
||||||
|
.withDescription(description)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue