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 Context APIs

All application command contexts extend the ApplicationCommandContext type, which provides some basic common APIs. These APIs are available in the action { } block regardless of interaction type, so you should familiarise yourself with them!

The ApplicationCommandContext type extends the base CommandContext type, so it inherits the APIs defined there. For more information on the APIs common to all command contexts, see the basic command context API page.

All application command contexts also extend one of the interaction context types (TODO), unless you're writing an unsafe command (TODO).

abstract class ApplicationCommandContext : CommandContext

Abstract base type representing everything that all application command contexts have in common.

Constructor Arguments
val genericEventType: ApplicationCommandInteractionCreateEvent

Generic event object representing the interaction that triggered this command execution.

Usually accessed via a more specific event property in each command's specific context type.

val genericCommandType: ApplicationCommand

Generic event object representing the current command object.

Usually accessed via a more specific command property in each command's specific context type.

cacheType: MutableMap<String, Any>

Map representing a data cache shared with the command's registered checks.

Properties

val appPermissionsType: Permissions?

The permissions your bot has in this command execution context - that is, based on the current guild, roles and channel.

This is always null if the command was executed in a DM.

val botSettingsType: ExtensibleBotBuilder

Quick access to your bot's settings.



open var channelType: MessageChannelBehavior

The channel this command invocation happened in.

open var guildType: GuildBehavior?

The guild this command invocation happened in, or null if it happened in a DM.

open var memberType: MemberBehavior?

The guild member that caused this command invocation, or null if:

  • This command invocation happened in a DM.
  • This command invocation was caused by a webhook.
open var messageType: Message

The Discord message that caused this command invocation.

open var userType: UserBehavior?

The Discord user that caused this command invocation, or null if it was a webhook.