1
0

MAYBE ALSO IMPLEMENT CHANGES THAT WERE MADE SINCE THIS BRANCH WAS MADE

This commit is contained in:
Jannik Reimers 2024-11-28 09:06:11 +01:00
parent f0d9a037c1
commit e78864ae8b
Signed by: jansel
GPG Key ID: 39C62D7D5233CFD0

View File

@ -25,12 +25,37 @@ class Twitch : KordExKoinComponent {
runBlocking {
launch {
val streamer = StreamerCollection().getData(it.channel.name)
val channel = botRef!!.kordRef.getChannelOf<GuildMessageChannel>(streamer!!.servers.first().channelId)
val role = streamer.servers.first().roleId
if (role != null) {
channel?.createMessage("<@&$role> https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
} else {
channel?.createMessage("${it.channel.name} went live: ${it.stream.title}")
for (server in streamer!!.servers) {
val channel = botRef!!.kordRef.getChannelOf<GuildMessageChannel>(server.channelId)
val role = server.roleId
val livemessage = server.liveMessage
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}")
}
} 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 {
channel?.createMessage("https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
}
}
}
}
}