Skip to content

Commit

Permalink
[#69] Add kord DSL function to EBB. Nice.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Aug 21, 2021
1 parent 149b044 commit eddd1a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public open class ExtensibleBot(public val settings: ExtensibleBotBuilder, priva
}

enableShutdownHook = settings.hooksBuilder.kordShutdownHook

settings.kordBuilders.forEach { it() }
}

loadModule { single { kord } bind Kord::class }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import dev.kord.core.Kord
import dev.kord.core.behavior.GuildBehavior
import dev.kord.core.behavior.UserBehavior
import dev.kord.core.behavior.channel.ChannelBehavior
import dev.kord.core.builder.kord.KordBuilder
import dev.kord.core.builder.kord.Shards
import dev.kord.core.cache.KordCacheBuilder
import dev.kord.core.event.interaction.InteractionCreateEvent
Expand Down Expand Up @@ -86,6 +87,9 @@ public open class ExtensibleBotBuilder {
/** @suppress Builder that shouldn't be set directly by the user. **/
public val slashCommandsBuilder: SlashCommandsBuilder = SlashCommandsBuilder()

/** @suppress List of Kord builders, shouldn't be set directly by the user. **/
public val kordBuilders: MutableList<suspend KordBuilder.() -> Unit> = mutableListOf()

/** Logging level Koin should use, defaulting to ERROR. **/
public var koinLogLevel: Level = Level.ERROR

Expand All @@ -109,6 +113,21 @@ public open class ExtensibleBotBuilder {
builder(hooksBuilder)
}

/**
* DSL function allowing for additional Kord builders to be specified, allowing for direct customisation of the
* Kord object.
*
* Multiple builders may be registered, and they'll be called in the order they were registered here. Builders are
* called after Kord Extensions has applied its own builder actions - so you can override the changes it makes here
* if they don't suit your bot.
*
* @see KordBuilder
*/
@BotBuilderDSL
public fun kord(builder: suspend KordBuilder.() -> Unit) {
kordBuilders.add(builder)
}

/**
* DSL function used to configure the bot's message command options.
*
Expand Down

0 comments on commit eddd1a0

Please sign in to comment.