![JAR search and dependency download from the Maven repository](/logo.png)
io.github.freya022.botcommands.internal.commands.text.TextCommandsBuilder.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.commands.text
import io.github.freya022.botcommands.api.commands.text.provider.TextCommandManager
import io.github.freya022.botcommands.api.commands.text.provider.TextCommandProvider
import io.github.freya022.botcommands.api.core.annotations.BEventListener
import io.github.freya022.botcommands.api.core.events.FirstGuildReadyEvent
import io.github.freya022.botcommands.api.core.service.annotations.BService
import io.github.freya022.botcommands.api.core.service.getInterfacedServices
import io.github.freya022.botcommands.internal.core.BContextImpl
import io.github.oshai.kotlinlogging.KotlinLogging
@BService
internal class TextCommandsBuilder {
@BEventListener
internal fun onFirstReady(event: FirstGuildReadyEvent, context: BContextImpl) {
try {
val manager = TextCommandManager(context)
context.serviceContainer
.getInterfacedServices()
.forEach { textCommandProvider ->
textCommandProvider.declareTextCommands(manager)
}
manager.textCommands.map.values.forEach { context.textCommandsContext.addTextCommand(it) }
} catch (e: Throwable) {
KotlinLogging.logger { }.error(e) { "An error occurred while updating text commands" }
} finally {
context.eventDispatcher.removeEventListener(this)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy