Skip to content

Commit

Permalink
MAYBE ALSO IMPLEMENT CHANGES THAT WERE MADE SINCE THIS BRANCH WAS MADE
Browse files Browse the repository at this point in the history
  • Loading branch information
NotJansel committed Nov 28, 2024
1 parent accd4d1 commit 45da7ed
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/main/kotlin/dev/jansel/feixiao/utils/Twitch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}
}
}
}
Expand Down

0 comments on commit 45da7ed

Please sign in to comment.