![JAR search and dependency download from the Maven repository](/logo.png)
io.github.freya022.botcommands.internal.components.handler.ComponentDescriptor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of BotCommands Show documentation
Show all versions of BotCommands Show documentation
A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.
package io.github.freya022.botcommands.internal.components.handler
import io.github.freya022.botcommands.api.commands.builder.CustomOptionBuilder
import io.github.freya022.botcommands.internal.IExecutableInteractionInfo
import io.github.freya022.botcommands.internal.core.BContextImpl
import io.github.freya022.botcommands.internal.core.options.OptionType
import io.github.freya022.botcommands.internal.core.reflection.MemberParamFunction
import io.github.freya022.botcommands.internal.parameters.OptionParameter
import io.github.freya022.botcommands.internal.transformParameters
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent
import kotlin.reflect.jvm.jvmErasure
class ComponentDescriptor internal constructor(
context: BContextImpl,
override val eventFunction: MemberParamFunction
) : IExecutableInteractionInfo {
override val parameters: List
init {
parameters = eventFunction.transformParameters(
builderBlock = { function, parameter, declaredName ->
when (context.serviceContainer.canCreateService(parameter.type.jvmErasure)) {
//No error => is a service
null -> CustomOptionBuilder(OptionParameter.fromSelfAggregate(function, declaredName))
else -> ComponentHandlerOptionBuilder(OptionParameter.fromSelfAggregate(function, declaredName))
}
},
aggregateBlock = { ComponentHandlerParameter(context, it) }
)
}
internal val optionSize = parameters.sumOf { p -> p.allOptions.count { o -> o.optionType == OptionType.OPTION } }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy