stream info add

This commit is contained in:
dalbodeule
2024-06-17 16:10:34 +09:00
parent 09bb485a13
commit 3f60348ace
5 changed files with 92 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package space.mori.chzzk_bot.services
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update
import space.mori.chzzk_bot.models.User
import space.mori.chzzk_bot.models.Users
@@ -43,4 +44,18 @@ object UserService {
User.all().toList()
}
}
fun updateLiveAlert(id: Int, guildId: Long, channelId: Long, alertMessage: String?) {
return transaction {
val updated = Users.update({ Users.id eq id }) {
it[Users.liveAlertGuild] = guildId
it[Users.liveAlertChannel] = channelId
it[Users.liveAlertMessage] = alertMessage ?: ""
}
if(updated == 0) throw RuntimeException("User not found! $id")
User.find(Users.id eq id)
}
}
}