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

Basic Command APIs

All command types extend the Command type, which provides some basic common APIs. These APIs are available regardless of command type, so you should familiarise yourself with them!

abstract class Command : Lockable, KordExKoinComponent

Abstract base type representing everything that all commands have in common.

Constructor Arguments
val extensionType: Extension

The extension that registered this command.

Functions

requireBotPermissions(...)

Specify any permissions your bot needs to be able to execute the command. Permissions will be checked against the command's execution context - the current guild and channel.

Arguments
permsTypes:PermissionPermissions

The permissions your bot requires.

Show/Hide Internal APIs
open suspend checkBotPerms(...)

Check the permissions provided via the requireBotPermissions function, throwing a DiscordRelayedException with a suitable error if your boot doesn't have the required permissions.

Arguments
contextType: CommandContext

Command context used to check permissions.

open suspend emitEventAsync(...)Returns:Job

Quick shortcut to emit a CommandEvent without blocking the current coroutine.

Arguments
eventType: CommandEvent

Event object to emit.

Properties

val extensionType: Extension

The extension that registered this command.

open var nameType: key

Command name, used when invoking the command and shown in help commands.



val kordType: Kord

Quick access to your bot's backing Kord instance.

val sentryType: SentryAdapter
val settingsType: ExtensibleBotBuilder

Quick access to your bot's settings.

val translationsProviderType: TranslationsProvider
Show/Hide Internal APIs
open val nameTranslationCacheType: MutableMap<Locale, String>Default: mutableMapOf()

Command name translation cache, used to avoid repeated translation calls.

open val requiredPermsType: MutableSet<Permission>Default: mutableSetOf()

Set of permissions required to execute the command, provided via requireBotPermissions.