also maybe enable the database?
This commit is contained in:
parent
c5779a353d
commit
9c4292f515
2 changed files with 28 additions and 0 deletions
|
@ -5,6 +5,7 @@ package dev.jansel.aglaea
|
|||
|
||||
import com.github.twitch4j.TwitchClient
|
||||
import dev.jansel.aglaea.extensions.ReplayExtension
|
||||
import dev.jansel.aglaea.utils.database
|
||||
import dev.jansel.aglaea.utils.twitch
|
||||
import dev.kord.common.entity.Snowflake
|
||||
import dev.kordex.core.ExtensibleBot
|
||||
|
@ -27,6 +28,7 @@ suspend fun main() {
|
|||
extensions {
|
||||
add(::ReplayExtension)
|
||||
}
|
||||
database(true)
|
||||
twitch(true)
|
||||
if (devMode) {
|
||||
// In development mode, load any plugins from `src/main/dist/plugin` if it exists.
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package dev.jansel.aglaea.utils
|
||||
|
||||
import dev.jansel.aglaea.database.Database
|
||||
import dev.jansel.aglaea.database.collections.MetaCollection
|
||||
import dev.jansel.aglaea.database.collections.ReplayCollection
|
||||
import dev.jansel.aglaea.twitchClient
|
||||
import dev.kordex.core.builders.ExtensibleBotBuilder
|
||||
import dev.kordex.core.utils.env
|
||||
import dev.kordex.core.utils.loadModule
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.koin.dsl.bind
|
||||
|
||||
val twitchcid = env("TWITCH_CLIENT_ID")
|
||||
|
@ -11,6 +15,28 @@ val twitchcs = env("TWITCH_CLIENT_SECRET")
|
|||
val twitchToken = env("TWITCH_OAUTH_TOKEN")
|
||||
val mongoUri = env("MONGO_URI")
|
||||
|
||||
suspend inline fun ExtensibleBotBuilder.database(migrate: Boolean) {
|
||||
val db = Database()
|
||||
|
||||
hooks {
|
||||
beforeKoinSetup {
|
||||
loadModule {
|
||||
single { db } bind Database::class
|
||||
}
|
||||
|
||||
loadModule {
|
||||
single { MetaCollection() } bind MetaCollection::class
|
||||
single { ReplayCollection() } bind ReplayCollection::class
|
||||
}
|
||||
|
||||
if (migrate) {
|
||||
runBlocking { db.migrate() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
suspend inline fun ExtensibleBotBuilder.twitch(active: Boolean) {
|
||||
hooks {
|
||||
beforeKoinSetup {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue