Arguments
While most command types support arguments, Context Commands don't. If you need to collect anything from users who run these commands, you'll need to use Modals instead.
Arguments represent the parameters users supply to your commands.
You can define arguments by creating a class extending the Arguments type, containing properties created with
converter builder functions:
class MyArguments : Arguments() {
val target by user {
name = "target"
description = "Target user"
}
}
Once you've created an arguments class, provide it to your commands' builder functions.
This will make the parsed arguments available via the arguments property in your command's action { } block:
publicSlashCommand(arguments = ::MyArguments) {
name = "my-command"
action {
respond {
content = "Target user: ${arguments.user.mention}"
}
}
}
Arguments API
The Arguments type exposes a few settings you can use to configure how Kord Extensions should parse your commands'
arguments, among other things.
Base class you should extend to represent a set of command arguments.
Whether to attempt to parse previous arguments when handling an autocompletion event.
When working with Slash Commands and Discord's autocomplete system, setting
this to true allows your autoComplete { } blocks to retrieve the value for the other arguments, if the user
provides them.
Some converter types provide a default autoComplete { } block, and you'll need to set this property to true
when using them.
Show/Hide Internal APIs
The following APIs are intended for internal use, but may be helpful if you're developing your own related libraries.
Adds a converter to this class' list of arguments, wrapping it in an Argument object.
Used internally by the converter builder functions.
The data type the given converter returns.
Display name shown on Discord, used in help messages, and the key for keyword arguments in Chat Commands.
Description shown on Discord, and used in help messages.
Converter object to add.
List of wrapped converter objects representing command arguments, stored in the order they were defined.
Validation function called by Kord Extensions, ensuring your arguments classes make sense.
Resolved locale for the current command execution.