CommandContext

abstract class CommandContext(val command: Command, val eventObj: Event, val commandName: Key, val cache: MutableStringKeyedMap<Any>) : KordExKoinComponent, TranslatableContext

Light wrapper class representing the context for a command's action.

This is what this refers to in a command action body. You shouldn't have to instantiate this yourself.

Parameters

command

Respective command for this context object.

eventObj

Event that triggered this command.

commandName

Command name given by the user to invoke the command - lower-cased.

cache

Data cache map shared with the defined checks.

Inheritors

Constructors

Link copied to clipboard
constructor(command: Command, eventObj: Event, commandName: Key, cache: MutableStringKeyedMap<Any>)

Properties

Link copied to clipboard
Link copied to clipboard
open val command: Command
Link copied to clipboard
open val commandName: Key
Link copied to clipboard
open val eventObj: Event
Link copied to clipboard
open override var resolvedLocale: Locale?

Cached locale variable, stored and retrieved by getLocale.

Link copied to clipboard

Current Sentry context, containing breadcrumbs and other goodies.

Functions

Link copied to clipboard
abstract suspend fun getChannel(): ChannelBehavior

Extract channel information from event data.

Link copied to clipboard
abstract suspend fun getGuild(): GuildBehavior?

Extract guild information from event data, if that context is available.

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

Get the associated Koin instance.

Link copied to clipboard
open suspend override fun getLocale(): Locale

Resolve the locale for this context, storing it in resolvedLocale.

Link copied to clipboard
abstract suspend fun getMember(): MemberBehavior?

Extract member information from event data, if that context is available.

Link copied to clipboard
abstract suspend fun getUser(): UserBehavior?

Extract user information from event data, if that context is available.

Link copied to clipboard
abstract suspend fun populate()

Called before processing, used to populate any extra variables from event data.

Link copied to clipboard
suspend fun CommandContext.waitForResponse(timeout: Long, filter: suspend MessageCreateEvent.() -> Boolean = { true }): Message?

Wait for a message by the user that invoked this command, in the channel it was invoked in, using the given timeout (in milliseconds) and extra filter function.