ApplicationCommandRegistry

Abstract class representing common behavior for application command registries.

Deals with the registration and syncing of, and dispatching to, all application commands. Subtypes should build their functionality on top of this type.

See also

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Command parser to use for slash commands.

Link copied to clipboard
open val bot: ExtensibleBot

Current instance of the bot.

Link copied to clipboard

Whether the initial sync has been finished, and commands should be registered directly.

Link copied to clipboard
open val kord: Kord

Kord instance, backing the ExtensibleBot.

Link copied to clipboard
val ApplicationCommandType.name: String

Quick access to the human-readable name for a Discord application command type.

Functions

Link copied to clipboard
open suspend fun createDiscordCommand(command: ApplicationCommand<*>): Snowflake?

Creates a KordEx ApplicationCommand as discord command and returns the created command's id as Snowflake.

Link copied to clipboard
open suspend fun createDiscordMessageCommand(command: MessageCommand<*, *>): Snowflake?

Creates a KordEx MessageCommand as discord command and returns the created command's id as Snowflake.

Link copied to clipboard
open suspend fun createDiscordSlashCommand(command: SlashCommand<*, *, *>): Snowflake?

Creates a KordEx SlashCommand as discord command and returns the created command's id as Snowflake.

Link copied to clipboard
open suspend fun createDiscordUserCommand(command: UserCommand<*, *>): Snowflake?

Creates a KordEx UserCommand as discord command and returns the created command's id as Snowflake.

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

Get the associated Koin instance.

Link copied to clipboard
abstract suspend fun handle(event: AutoCompleteInteractionCreateEvent)

Event handler for autocomplete interactions.

abstract suspend fun handle(event: ChatInputCommandInteractionCreateEvent)

Event handler for slash commands.

abstract suspend fun handle(event: MessageCommandInteractionCreateEvent)

Event handler for message commands.

abstract suspend fun handle(event: UserCommandInteractionCreateEvent)

Event handler for user commands.

Link copied to clipboard
suspend fun initialRegistration()

Handles the initial registration of commands, after extensions have been loaded.

Link copied to clipboard
open fun ApplicationCommand<*>.matches(locale: Locale, other: ApplicationCommand): Boolean

Check whether the type and name of an extension-registered application command matches a Discord one.

Link copied to clipboard
abstract suspend fun register(command: MessageCommand<*, *>): MessageCommand<*, *>?

Register a MessageCommand to the registry.

abstract suspend fun register(command: SlashCommand<*, *, *>): SlashCommand<*, *, *>?

Register a SlashCommand to the registry.

abstract suspend fun register(command: UserCommand<*, *>): UserCommand<*, *>?

Register a UserCommand to the registry.

open suspend fun ChatInputCreateBuilder.register(locale: Locale, command: SlashCommand<*, *, *>)

Registration logic for slash commands, extracted for clarity.

open fun GlobalMessageCommandCreateBuilder.register(locale: Locale, command: MessageCommand<*, *>)
open fun MessageCommandCreateBuilder.register(locale: Locale, command: MessageCommand<*, *>)

Registration logic for message commands, extracted for clarity.

open fun GlobalUserCommandCreateBuilder.register(locale: Locale, command: UserCommand<*, *>)
open fun UserCommandCreateBuilder.register(locale: Locale, command: UserCommand<*, *>)

Registration logic for user commands, extracted for clarity.

Link copied to clipboard
open suspend fun <T : ApplicationCommand<*>> registerAll(vararg commands: T): List<T>

Register multiple slash commands.

Link copied to clipboard
open fun GlobalApplicationCommandCreateBuilder.registerGlobalPermissions(locale: Locale, command: ApplicationCommand<*>)

Registers the global permissions of command.

Link copied to clipboard
open fun ApplicationCommandCreateBuilder.registerGuildPermissions(locale: Locale, command: ApplicationCommand<*>)

Registers the guild permission of command.

Link copied to clipboard
abstract suspend fun unregister(command: MessageCommand<*, *>, delete: Boolean = true): MessageCommand<*, *>?

Unregister a message command.

abstract suspend fun unregister(command: SlashCommand<*, *, *>, delete: Boolean = true): SlashCommand<*, *, *>?

Unregister a slash command.

abstract suspend fun unregister(command: UserCommand<*, *>, delete: Boolean = true): UserCommand<*, *>?

Unregister a user command.

Link copied to clipboard
open suspend fun unregisterGeneric(command: ApplicationCommand<*>, delete: Boolean = true): ApplicationCommand<*>?

Unregister a generic ApplicationCommand.