All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.freya022.botcommands.api.components.Button.kt Maven / Gradle / Ivy

Go to download

A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.

There is a newer version: 3.0.0-alpha.18
Show newest version
package io.github.freya022.botcommands.api.components

import io.github.freya022.botcommands.api.components.event.ButtonEvent
import io.github.freya022.botcommands.internal.components.controller.ComponentController
import kotlinx.coroutines.TimeoutCancellationException
import net.dv8tion.jda.api.entities.emoji.Emoji
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle
import net.dv8tion.jda.api.interactions.components.buttons.Button as JDAButton

class Button internal constructor(private val componentController: ComponentController, button: JDAButton) : JDAButton by button, IdentifiableComponent {
    override fun withDisabled(disabled: Boolean): Button {
        return Button(componentController, super.withDisabled(disabled))
    }

    override fun withEmoji(emoji: Emoji?): Button {
        return Button(componentController, super.withEmoji(emoji))
    }

    override fun withLabel(label: String): Button {
        return Button(componentController, super.withLabel(label))
    }

    override fun withId(id: String): Button {
        return Button(componentController, super.withId(id))
    }

    override fun withUrl(url: String): Button {
        return Button(componentController, super.withUrl(url))
    }

    override fun withStyle(style: ButtonStyle): Button {
        return Button(componentController, super.withStyle(style))
    }

    /**
     * **Awaiting on a component that is part of a group is undefined behavior**
     *
     * @throws TimeoutCancellationException If the timeout set in the component builder has been reached
     */
    @JvmSynthetic
    override suspend fun await(): ButtonEvent = componentController.awaitComponent(this)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy