Work In Progress
This documentation is in beta. It's missing lots of content, search is broken, and many links go nowhere. These problems will be fixed before release, but there's plenty of work left!
Skip to main content

Commands

The command builders allow you to configure Kord Extensions' command frameworks. Kord Extensions supports two primary command types:

  • Application commands, which include message, slash, and user commands
  • Chat commands, which are commands via messages in Discord channels
danger

With the introduction of slash commands, Kord Extensions has elected to de-prioritise chat commands. This means that we disable them by default, and you'll need to enable them if you want to use them.

We intend to support chat commands indefinitely. However, please note that most bots don't use them, and this means that there may be subtle or unknown bugs present within the chat commands framework. If you notice anything unusual or broken, please don't hesitate to submit a Pull Request, open an issue, or contact us on Discord.

For more information on commands and how to write them, see [this page] and [that page].

Application Commands

The applicationCommands { } builder allows you to configure the application commands framework, which includes context (user and message) commands and slash commands.

ExtensibleBot(TOKEN) {
// ...

applicationCommands {
defaultGuild(TEST_GUILD_ID)
}
}

Builders

applicationCommandRegistry { ... }Lambda Returns: ApplicationCommandRegistry

Register a callback that constructs and returns an alternative implementation of the ApplicationCommandRegistry type, if needed.

messageCommandCheck { ... }Receiver: CheckContext<MessageCommandInteractionCreateEvent>

Register a check that will apply to all of your bot's message commands.

slashCommandCheck { ... }Receiver: CheckContext<ChatInputCommandInteractionCreateEvent>

Register a check that will apply to all of your bot's slash commands.

userCommandCheck { ... }Receiver: CheckContext<UserCommandInteractionCreateEvent>

Register a check that will apply to all of your bot's user commands.

Functions

defaultGuild(...)

Specify a guild to register all global application commands to. This will apply to all application commands that don't have a default guild specified.

This function sets the defaultGuild property, which you can set manually instead if you prefer.

Arguments
idTypes:Snowflake?String?ULong?

ID representing the required default guild.

Properties

var enabledType: BooleanDefault: true

Whether application commands should be enabled.

Setting this to false disables the entire feature.

var registerType: BooleanDefault: true

Whether to automatically register commands with Discord, both during and after startup.

Setting this to false only prevents command registration --- users can still run commands. This may be useful for multi-process bots, or bots with commands you register externally.

Chat Commands

The chatCommands { } builder allows you to configure the chat commands framework, which handles the parsing and processing of chat commands.

ExtensibleBot(TOKEN) {
// ...

chatCommands {
defaultPrefix = "!"
enabled = true
invokeOnMention = true
}
}

Builders

check { ... }Receiver: CheckContext<MessageCreateEvent>

Register a check that will apply to all of your bot's chat commands.

prefix { ... }Receiver: MessageCreateEventLambda Returns: String

Set the prefix callback, which allows you to provide different command prefixes for different contexts.

Lambda Arguments
defaultPrefixType: String

The configured default prefix. Your lambda should return this if no custom prefix is required.

registry { ... }Lambda Returns: ChatCommandRegistry

Register a callback that constructs and returns an alternative implementation of the ChatCommandRegistry type, if needed.

Properties

var defaultPrefixType: StringDefault: "!"

The default command prefix, required before the name of a chat command at the start of a message. Use the prefix { } builder to supply a dynamic command prefix.

var enabledType: BooleanDefault: false

Whether chat commands should be enabled. Leaving this set to false disables the entire feature.

As it's disabled by default, you'll need to set this to true if you need your bot to support chat commands.

var ignoreSelfType: BooleanDefault: true

Whether to ignore messages sent by this bot. Setting this to false means that the bot will execute commands based on the content of its own messages.

var invokeOnMentionType: BooleanDefault: true

Whether users should be able to execute commands by mentioning/pinging the bot at the start of the message, instead of using a command prefix.