reformat code and optimize imports (IntelliJ internal function)
This commit is contained in:
parent
fce192d295
commit
20da6a5dda
@ -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}")
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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() {
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user