argOrDefault

fun <T : Any> CommandContext.argOrDefault(index: Int, type: KClass<T>, default: T): T

Extension function for CommandContext that retrieves and parses the argument at the specified index, or returns a default value if the argument is missing.

Return

The parsed argument of type T or the default value.

Parameters

index

The index of the argument to retrieve.

type

The type of the argument to parse.

default

The default value to return if the argument is missing.


inline fun <T : Any> CommandContext.argOrDefault(index: Int, default: T): T

Inline extension function for CommandContext that retrieves and parses the argument at the specified index, or returns a default value if the argument is missing.

This function infers the type T from the reified type argument.

Return

The parsed argument of type T or the default value.

Parameters

index

The index of the argument to retrieve.

default

The default value to return if the argument is missing.