diff --git a/src/main/kotlin/dev/jansel/feixiao/App.kt b/src/main/kotlin/dev/jansel/feixiao/App.kt index 85a790f..299c7a5 100644 --- a/src/main/kotlin/dev/jansel/feixiao/App.kt +++ b/src/main/kotlin/dev/jansel/feixiao/App.kt @@ -10,7 +10,10 @@ import com.github.twitch4j.events.ChannelGoLiveEvent import dev.jansel.feixiao.database.collections.StreamerCollection import dev.jansel.feixiao.extensions.EventHooks import dev.jansel.feixiao.extensions.StreamerCommand -import dev.jansel.feixiao.utils.* +import dev.jansel.feixiao.utils.database +import dev.jansel.feixiao.utils.token +import dev.jansel.feixiao.utils.twitchcid +import dev.jansel.feixiao.utils.twitchcs import dev.kord.core.entity.channel.GuildMessageChannel import dev.kordex.core.ExtensibleBot import dev.kordex.core.i18n.SupportedLocales @@ -19,7 +22,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking var twitchClient: TwitchClient? = null -val logger = KotlinLogging.logger { } +val logger = KotlinLogging.logger { } suspend fun main() { val bot = ExtensibleBot(token) { @@ -51,22 +54,26 @@ suspend fun main() { if (role != null) { if (livemessage != null) { - channel?.createMessage(livemessage - .replace("{name}", it.channel.name) - .replace("{category}", it.stream.gameName) - .replace("{title}", it.stream.title) - .replace("{url}", "https://twitch.tv/${it.channel.name}") - .replace("{role}", "<@&$role>")) + channel?.createMessage( + livemessage + .replace("{name}", it.channel.name) + .replace("{category}", it.stream.gameName) + .replace("{title}", it.stream.title) + .replace("{url}", "https://twitch.tv/${it.channel.name}") + .replace("{role}", "<@&$role>") + ) } else { channel?.createMessage("<@&$role> https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}") } } else { if (livemessage != null) { - channel?.createMessage(livemessage - .replace("{name}", it.channel.name) - .replace("{category}", it.stream.gameName) - .replace("{title}", it.stream.title) - .replace("{url}", "https://twitch.tv/${it.channel.name}")) + channel?.createMessage( + livemessage + .replace("{name}", it.channel.name) + .replace("{category}", it.stream.gameName) + .replace("{title}", it.stream.title) + .replace("{url}", "https://twitch.tv/${it.channel.name}") + ) } else { channel?.createMessage("https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}") } diff --git a/src/main/kotlin/dev/jansel/feixiao/database/collections/StreamerCollection.kt b/src/main/kotlin/dev/jansel/feixiao/database/collections/StreamerCollection.kt index 8304211..651df09 100644 --- a/src/main/kotlin/dev/jansel/feixiao/database/collections/StreamerCollection.kt +++ b/src/main/kotlin/dev/jansel/feixiao/database/collections/StreamerCollection.kt @@ -20,7 +20,13 @@ class StreamerCollection : KordExKoinComponent { suspend fun getData(channelName: String): StreamerData? = collection.findOne(StreamerData::name eq channelName) - suspend fun updateData(guildId: Snowflake, channelId: Snowflake, streamerName: String, roleId: Snowflake?, liveMessage: String?) { + suspend fun updateData( + guildId: Snowflake, + channelId: Snowflake, + streamerName: String, + roleId: Snowflake?, + liveMessage: String? + ) { val coll = collection.findOne(StreamerData::name eq streamerName) if (coll != null) { collection.updateOne( @@ -34,7 +40,13 @@ class StreamerCollection : KordExKoinComponent { } } - suspend fun removeData(guildId: Snowflake, channelId: Snowflake, streamerName: String, roleId: Snowflake?, liveMessage: String?) { + suspend fun removeData( + guildId: Snowflake, + channelId: Snowflake, + streamerName: String, + roleId: Snowflake?, + liveMessage: String? + ) { val coll = collection.findOne(StreamerData::name eq streamerName) if (coll != null) { collection.updateOne( diff --git a/src/main/kotlin/dev/jansel/feixiao/extensions/EventHooks.kt b/src/main/kotlin/dev/jansel/feixiao/extensions/EventHooks.kt index 246afb1..0a49bd4 100644 --- a/src/main/kotlin/dev/jansel/feixiao/extensions/EventHooks.kt +++ b/src/main/kotlin/dev/jansel/feixiao/extensions/EventHooks.kt @@ -7,7 +7,6 @@ import dev.jansel.feixiao.twitchClient import dev.kord.core.event.gateway.ReadyEvent import dev.kordex.core.extensions.Extension import dev.kordex.core.extensions.event -import org.litote.kmongo.deleteMany import org.litote.kmongo.eq class EventHooks : Extension() { diff --git a/src/main/kotlin/dev/jansel/feixiao/extensions/StreamerCommand.kt b/src/main/kotlin/dev/jansel/feixiao/extensions/StreamerCommand.kt index 53bfedd..efafbac 100644 --- a/src/main/kotlin/dev/jansel/feixiao/extensions/StreamerCommand.kt +++ b/src/main/kotlin/dev/jansel/feixiao/extensions/StreamerCommand.kt @@ -31,7 +31,13 @@ class StreamerCommand : Extension() { } action { val streamer = arguments.streamer - StreamerCollection().updateData(guild!!.id, arguments.channel.id, streamer, arguments.role?.id, arguments.message) + StreamerCollection().updateData( + guild!!.id, + arguments.channel.id, + streamer, + arguments.role?.id, + arguments.message + ) twitchClient!!.clientHelper.enableStreamEventListener(streamer) respond { content = "Added streamer $streamer"