OptionalArg

class OptionalArg<I, O, O2>(    val name: String,     val type: Argument<I, O>,     default: suspend DiscordContext.() -> O2) : WrappedArgument<I, O, I, O2>

An optional argument with a default value.

Constructors

Link copied to clipboard
fun <I, O, O2> OptionalArg(    name: String,     type: Argument<I, O>,     default: suspend DiscordContext.() -> O2)

Functions

Link copied to clipboard
open suspend override fun generateExamples(context: DiscordContext): List<String>

A function called whenever an example of this type is needed.

Link copied to clipboard
open fun isOptional(): Boolean

Utility function to check that this Argument is an OptionalArg.

Link copied to clipboard
open fun multiple(): MultipleArg<I, O2>

Accept multiple inputs of this Argument.

Link copied to clipboard
open fun optional(default: O2): OptionalArg<I, O2, O2>

Make this argument optional and fall back to the default value if the conversion fails.

open fun optional(default: suspend (DiscordContext) -> O2): OptionalArg<I, O2, O2>

Make this argument optional and fall back to the default value if the conversion fails. Exposes a CommandEvent.

Link copied to clipboard
open fun optionalNullable(default: O2? = null): OptionalArg<I, O2, O2?>

Make this argument optional and fall back to the default value if the conversion fails.

open fun optionalNullable(default: suspend (DiscordContext) -> O2?): OptionalArg<I, O2, O2?>

Make this argument optional and fall back to the default value if the conversion fails. Exposes a CommandEvent.

Link copied to clipboard
open suspend override fun parse(args: MutableList<String>, discord: Discord): I?

Parse string input into the correct type handled by this argument.

Link copied to clipboard
open suspend override fun transform(input: I, context: DiscordContext): Result<O2>

Transforms a value produced by a slash command or by the parse function.

Properties

Link copied to clipboard
open override val description: String

A description of the data that this type represents.

Link copied to clipboard
open val innerType: Argument<I, O>

Get the innermost/raw type inside this argument.

Link copied to clipboard
open override val name: String

The display name for this type in documentations and examples.

Link copied to clipboard
open override val type: Argument<I, O>

The Argument that is wrapped.