SelectMenu

abstract class SelectMenu<C : SelectMenuContext, M : ModalForm>(timeoutTask: Task?) : ComponentWithAction<SelectMenuInteractionCreateEvent, C, M>

Abstract class representing a select (dropdown) menu component.

Inheritors

Constructors

Link copied to clipboard
constructor(timeoutTask: Task?)

Properties

Link copied to clipboard
lateinit var body: suspend C.(modal: M?) -> Unit

Component body, to be called when the component is interacted with.

Link copied to clipboard

Bot object.

Link copied to clipboard

Whether to use a deferred ack, which will prevent Discord's "Thinking..." message.

Link copied to clipboard
open var disabled: Boolean?

Whether this select menu is disabled.

Link copied to clipboard
open var id: String

Component's ID, a UUID by default.

Link copied to clipboard
val kord: Kord

Kord instance, backing the ExtensibleBot.

Link copied to clipboard
open override var locking: Boolean

Set this to true to lock execution with a Mutex.

Link copied to clipboard

The maximum number of choices that the user can make. Set to null for no maximum.

Link copied to clipboard

The minimum number of choices that the user must make.

Link copied to clipboard
open val modal: () -> M?
Link copied to clipboard
open override var mutex: Mutex?

Mutex object to use for locking.

Link copied to clipboard

Placeholder text to show before the user has selected any options.

Link copied to clipboard

Quick access to the command registry.

Link copied to clipboard
open val requiredPerms: MutableSet<Permission>

Bot permissions required to be able to run execute this component's action.

Link copied to clipboard

Sentry adapter, for easy access to Sentry functions.

Link copied to clipboard

Bot settings object.

Link copied to clipboard
open val timeoutTask: Task?
Link copied to clipboard
open override val unitWidth: Int = 5

Component width, how many "slots" in one row it needs to be added to the row.

Functions

Link copied to clipboard
fun action(action: suspend C.(modal: M?) -> Unit)

Call this to supply a component body, to be called when the component is interacted with.

Link copied to clipboard
abstract fun apply(builder: ActionRowBuilder)

Called to apply the given component to a Kord ActionRowBuilder.

Link copied to clipboard
open suspend fun call(event: SelectMenuInteractionCreateEvent)

Override this to implement your component's calling logic. Check subtypes for examples!

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

Define a check which must pass for the component's body to be executed.

open fun check(check: CheckWithCache<SelectMenuInteractionCreateEvent>)

Overloaded check function to allow for DSL syntax.

Link copied to clipboard
open suspend fun checkBotPerms(context: C)

Checks whether the bot has the specified required permissions, throwing if it doesn't.

Link copied to clipboard
open fun disable()

Mark this select menu as disabled.

Link copied to clipboard
open fun enable()

Mark this select menu as enabled.

Link copied to clipboard
open suspend fun firstSentryBreadcrumb(context: C, component: SelectMenu<*, *>)

If enabled, adds the initial Sentry breadcrumb to the given context.

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

Get the associated Koin instance.

Link copied to clipboard
open suspend fun handleError(context: C, t: Throwable, button: SelectMenu<*, *>)

A general way to handle errors thrown during the course of a select menu action's execution.

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(vararg perms: Permission)

If your bot requires permissions to be able to execute this component's body, add them using this function.

Link copied to clipboard
abstract suspend fun respondText(context: C, message: Key, failureType: FailureReason<*>)

Override this to implement a way to respond to the user, regardless of whatever happens.

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

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

Link copied to clipboard
open suspend fun runStandardChecks(event: SelectMenuInteractionCreateEvent, 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 override fun validate()

Validation function, called to ensure the component is valid, throws exceptions if not.

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.