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
|
|
@ -475,4 +475,101 @@ public class MutableCommandBuilder<C : Any> {
|
|||
handler: CommandExecutionHandler<C>
|
||||
): MutableCommandBuilder<C> =
|
||||
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