Command

abstract class Command(val extension: Extension) : Lockable, KordExKoinComponent

Abstract base class representing the few things that command objects can have in common.

This should be used as a base class only for command types that aren't related to the other command types.

Inheritors

Constructors

Link copied to clipboard
constructor(extension: Extension)

Properties

Link copied to clipboard

The extension object this command belongs to.

Link copied to clipboard
val kord: Kord

Kord instance, backing the ExtensibleBot.

Link copied to clipboard
open override var locking: Boolean

Set this to true to lock command execution with a Mutex.

Link copied to clipboard
open override var mutex: Mutex?

Mutex object to use for locking.

Link copied to clipboard
open lateinit var name: Key

The name of this command, for invocation and help commands.

Link copied to clipboard

Translation cache, so we don't have to look up translations every time.

Link copied to clipboard
open val requiredPerms: MutableSet<Permission>

Permissions required to be able to run this command.

Link copied to clipboard

Sentry adapter, for easy access to Sentry functions.

Link copied to clipboard

Bot settings object.

Link copied to clipboard

Translations provider, for retrieving translations.

Functions

Link copied to clipboard
open suspend fun checkBotPerms(context: CommandContext)

Checks whether the bot has the specified required permissions, throwing if it doesn't.

Link copied to clipboard
open suspend fun emitEventAsync(event: CommandEvent<*, *>): Job

Quick shortcut for emitting a command event without blocking.

Link copied to clipboard
open override fun getKoin(): Koin

Get the associated Koin instance.

Link copied to clipboard
open suspend fun lock()

Lock the mutex, if locking is enabled - suspending until it's unlocked.

Link copied to clipboard
fun requireBotPermissions(perms: Permissions)
fun requireBotPermissions(vararg perms: Permission)

If your bot requires permissions to be able to execute the command, add them using this function.

Link copied to clipboard
open fun unlock()

Unlock the mutex, if it's locked.

Link copied to clipboard
open fun validate()

An internal function used to ensure that all of a command's required arguments are present and correct.

Link copied to clipboard
open suspend fun <T> withLock(body: suspend () -> T)

Lock the mutex (if locking is enabled), call the supplied callable, and unlock.