this should now work even better
This commit is contained in:
parent
4a437b5558
commit
0366cbbbd8
@ -12,7 +12,6 @@ import dev.jansel.feixiao.extensions.StreamerCommand
|
|||||||
import dev.jansel.feixiao.utils.*
|
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 io.github.oshai.kotlinlogging.KotlinLogging
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
@ -39,16 +38,37 @@ suspend fun main() {
|
|||||||
runBlocking {
|
runBlocking {
|
||||||
launch {
|
launch {
|
||||||
val streamer = StreamerCollection().getData(it.channel.name)
|
val streamer = StreamerCollection().getData(it.channel.name)
|
||||||
val channel = bot.kordRef.getChannelOf<GuildMessageChannel>(streamer!!.servers.first().channelId)
|
for (server in streamer!!.servers) {
|
||||||
val role = streamer.servers.first().roleId
|
val channel = bot.kordRef.getChannelOf<GuildMessageChannel>(server.channelId)
|
||||||
|
val role = server.roleId
|
||||||
|
val livemessage = server.liveMessage
|
||||||
|
|
||||||
if (role != null) {
|
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>"))
|
||||||
|
} else {
|
||||||
channel?.createMessage("<@&$role> https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
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}"))
|
||||||
} else {
|
} else {
|
||||||
channel?.createMessage("https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
channel?.createMessage("https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bot.start()
|
bot.start()
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class StreamerCommand : Extension() {
|
|||||||
}
|
}
|
||||||
action {
|
action {
|
||||||
val streamer = arguments.streamer
|
val streamer = arguments.streamer
|
||||||
StreamerCollection().updateData(guild!!.id, arguments.channel.id, streamer, arguments.role?.id)
|
StreamerCollection().updateData(guild!!.id, arguments.channel.id, streamer, arguments.role?.id, arguments.message)
|
||||||
twitchClient!!.clientHelper.enableStreamEventListener(streamer)
|
twitchClient!!.clientHelper.enableStreamEventListener(streamer)
|
||||||
respond {
|
respond {
|
||||||
content = "Added streamer $streamer"
|
content = "Added streamer $streamer"
|
||||||
@ -46,7 +46,7 @@ class StreamerCommand : Extension() {
|
|||||||
}
|
}
|
||||||
action {
|
action {
|
||||||
val streamer = arguments.streamer
|
val streamer = arguments.streamer
|
||||||
StreamerCollection().removeData(guild!!.id, channel.id, streamer, null)
|
StreamerCollection().removeData(guild!!.id, channel.id, streamer, null, null)
|
||||||
respond {
|
respond {
|
||||||
content = "Removed streamer $streamer"
|
content = "Removed streamer $streamer"
|
||||||
}
|
}
|
||||||
@ -70,6 +70,10 @@ class StreamerCommand : Extension() {
|
|||||||
name = "role"
|
name = "role"
|
||||||
description = "Role to ping when the streamer goes live"
|
description = "Role to ping when the streamer goes live"
|
||||||
}
|
}
|
||||||
|
val message by string {
|
||||||
|
name = "message"
|
||||||
|
description = "Message to send when the streamer goes live. Possible placeholders: {url}, {name}, {title}, {category}, {role} (if set)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class RemoveStreamerArgs : Arguments() {
|
inner class RemoveStreamerArgs : Arguments() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user