ApplicationCommand

abstract class ApplicationCommand<E : InteractionCreateEvent>(val extension: Extension) : Command, KordExKoinComponent

Abstract class representing an application command - extend this for actual implementations.

Parameters

extension

Extension this application command belongs to.

Inheritors

Constructors

Link copied to clipboard
constructor(extension: Extension)

Properties

Link copied to clipboard

Whether to allow everyone to use this command by default.

Link copied to clipboard

Enables or disables the command in DMs.

Link copied to clipboard
open var defaultMemberPermissions: Permissions?

Default set of Permissions required to use the command on a guild.

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

A Localised version of name. Lower-cased if this is a slash command.

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

Quick access to the command registry.

Link copied to clipboard
open override 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.

Link copied to clipboard
abstract val type: ApplicationCommandType

Discord-side command type, for matching up.

Functions

Link copied to clipboard
abstract suspend fun call(event: E, cache: MutableStringKeyedMap<Any>)

Override this to implement the calling logic for your subclass.

Link copied to clipboard
open fun check(vararg checks: CheckWithCache<E>)

Define a check which must pass for the command to be executed.

open fun check(check: CheckWithCache<E>)

Overloaded check function to allow for DSL syntax.

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 doCall(event: E)

Called in order to execute the command.

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 fun guild(guild: Snowflake?)

Specify a specific guild for this application command to be locked to.

Link copied to clipboard
fun localise(key: Key, lowerCase: Boolean = false): Localised<String>

Localises a property by its key for this command.

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
fun requirePermission(vararg permissions: Permission)

This will register a requirement for permissions with Discord.

Link copied to clipboard
open suspend fun runChecks(event: E, cache: MutableStringKeyedMap<Any>): Boolean

Override this in order to implement any subclass-specific checks.

Link copied to clipboard
open suspend fun runStandardChecks(event: E, cache: MutableStringKeyedMap<Any>): Boolean

Runs standard checks that can be handled in a generic way, without worrying about subclass-specific checks.

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.