1
0

change the ugly println stuff to prettier logging

This commit is contained in:
Jannik Reimers 2024-11-06 23:20:26 +01:00
parent 5e8f88b719
commit 816fe4bb34
Signed by: jansel
GPG Key ID: 39C62D7D5233CFD0
2 changed files with 6 additions and 3 deletions

View File

@ -13,10 +13,12 @@ import dev.jansel.feixiao.utils.*
import dev.kord.core.entity.channel.GuildMessageChannel import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kordex.core.ExtensibleBot import dev.kordex.core.ExtensibleBot
import dev.kordex.data.api.DataCollection import dev.kordex.data.api.DataCollection
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
var twitchClient: TwitchClient? = null var twitchClient: TwitchClient? = null
val logger = KotlinLogging.logger { }
suspend fun main() { suspend fun main() {
val bot = ExtensibleBot(token) { val bot = ExtensibleBot(token) {
@ -34,7 +36,7 @@ suspend fun main() {
.build() .build()
twitchClient!!.eventManager.onEvent(ChannelGoLiveEvent::class.java) { twitchClient!!.eventManager.onEvent(ChannelGoLiveEvent::class.java) {
println("${it.channel.name} went live!") logger.info { "${it.channel.name} went live!" }
runBlocking { runBlocking {
launch { launch {
val streamer = StreamerCollection().getData(it.channel.name) val streamer = StreamerCollection().getData(it.channel.name)

View File

@ -1,6 +1,7 @@
package dev.jansel.feixiao.extensions package dev.jansel.feixiao.extensions
import dev.jansel.feixiao.database.collections.StreamerCollection import dev.jansel.feixiao.database.collections.StreamerCollection
import dev.jansel.feixiao.logger
import dev.jansel.feixiao.twitchClient import dev.jansel.feixiao.twitchClient
import dev.kord.core.event.gateway.ReadyEvent import dev.kord.core.event.gateway.ReadyEvent
import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.Extension
@ -12,12 +13,12 @@ class EventHooks : Extension() {
override suspend fun setup() { override suspend fun setup() {
event<ReadyEvent> { event<ReadyEvent> {
action { action {
println("Bot is ready!") logger.info { "Bot is ready!" }
kord.editPresence { listening("the database") } kord.editPresence { listening("the database") }
// check every entry in the database and enable the stream event listener // check every entry in the database and enable the stream event listener
StreamerCollection().collection.find().toList().forEach { StreamerCollection().collection.find().toList().forEach {
twitchClient!!.clientHelper.enableStreamEventListener(it.name) twitchClient!!.clientHelper.enableStreamEventListener(it.name)
println("Enabled stream event listener for ${it.name}") logger.info { "Enabled stream event listener for ${it.name}" }
} }
} }
} }