JDASelectMenuListener

@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class JDASelectMenuListener(val name: String = "")(source)

Declares this function as a select menu listener with the given name.

Requirements

Option types

Type-safe bindings in Kotlin

You can use the bindWith extensions to safely pass data, in this case you don't need to set the listener name:

@Command
class SlashTypeSafeSelectMenus(private val selectMenus: SelectMenus) : ApplicationCommand() {
    @JDASlashCommand(name = "type_safe_select_menus", description = "Demo of Kotlin type-safe bindings")
    suspend fun onSlashTypeSafeSelectMenus(event: GuildSlashEvent, @SlashOption argument: String) {
        val selectMenu = selectMenus.entitySelectMenu(EntitySelectMenu.SelectTarget.ROLE).persistent {
            bindTo(::onTestSelect, argument)
        }

        event.replyComponents(selectMenu.into()).await()
    }

    @JDASelectMenuListener // No need for a name if you use the type-safe bindTo extensions
    suspend fun onTestSelect(event: EntitySelectEvent, @ComponentData argument: String) {
        event.reply_("The argument was: $argument", ephemeral = true).await()
    }
}

See also

@Aggregate

@Cooldown

@RateLimit

Properties

Link copied to clipboard
@get:JvmName(name = "value")
val name: String

Name of the select menu listener, referenced by IPersistentActionableComponent.bindTo.