ChatCommandContext

open class ChatCommandContext<T : Arguments>(val chatCommand: ChatCommand<out T>, val eventObj: MessageCreateEvent, val commandName: Key, val parser: StringParser, val argString: String, val cache: MutableStringKeyedMap<Any>) : CommandContext

Command context object representing the context given to chat commands.

Parameters

parser

String parser instance, if any - will be null if this isn't a chat command.

Constructors

Link copied to clipboard
constructor(chatCommand: ChatCommand<out T>, eventObj: MessageCreateEvent, commandName: Key, parser: StringParser, argString: String, cache: MutableStringKeyedMap<Any>)

Properties

Link copied to clipboard

String containing the command's unparsed arguments, raw, fresh from Discord itself.

Link copied to clipboard
open lateinit var arguments: T

Arguments object containing this command's parsed arguments.

Link copied to clipboard
Link copied to clipboard
open lateinit var channel: MessageChannelBehavior

Message channel this command happened in, if any.

Link copied to clipboard

Chat command object

Link copied to clipboard
open val command: Command
Link copied to clipboard
open val commandName: Key
Link copied to clipboard
val event: MessageCreateEvent

Event that triggered this command execution.

Link copied to clipboard
open val eventObj: Event
Link copied to clipboard
open var guild: GuildBehavior?

Guild this command happened in, if any.

Link copied to clipboard
open var member: MemberBehavior?

Guild member responsible for executing this command, if any.

Link copied to clipboard
open lateinit var message: Message

Message object containing this command invocation.

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

Link copied to clipboard
open var user: UserBehavior?

User responsible for executing this command, if any (if null, it's a webhook).

Functions

Link copied to clipboard
open suspend override fun getChannel(): MessageChannelBehavior

Extract channel information from event data.

Link copied to clipboard
open suspend override 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
open suspend override fun getMember(): MemberBehavior?

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

Link copied to clipboard
open suspend fun getMessage(): Message

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

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

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

Link copied to clipboard
suspend fun paginator(defaultGroup: Key = EMPTY_KEY, pingInReply: Boolean = true, targetChannel: MessageChannelBehavior? = null, targetMessage: Message? = null, body: suspend PaginatorBuilder.() -> Unit): MessageButtonPaginator

Convenience function to create a button paginator using a builder DSL syntax. Handles the contextual stuff for you.

Link copied to clipboard
open suspend override fun populate()

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

Link copied to clipboard
suspend fun Message.respondTranslated(key: Key, placeholders: Array<Any?> = arrayOf(), useReply: Boolean = true, pingInReply: Boolean = true): Message
suspend fun Message.respondTranslated(key: Key, placeholders: Map<String, Any?>, useReply: Boolean = true, pingInReply: Boolean = true): Message

Convenience function allowing for message responses with translated content.

Link copied to clipboard
suspend fun sendHelp(): Boolean

Generate and send the help embed for this command, using the first loaded extensions that implements HelpProvider.

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.