This commit is contained in:
dalbodeule 2024-08-15 20:32:31 +09:00
parent 8a3c64ab46
commit 35d8759ee3
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65
2 changed files with 8 additions and 3 deletions

View File

@ -239,6 +239,8 @@ class UserHandler(
CoroutineScope(Dispatchers.Default).launch { CoroutineScope(Dispatchers.Default).launch {
logger.info("${user.username} is live.") logger.info("${user.username} is live.")
reloadUser(UserService.getUser(user.id.value)!!)
logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}") logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}")
listener.connectAsync().await() listener.connectAsync().await()

View File

@ -31,12 +31,15 @@ class Discord: ListenerAdapter() {
companion object { companion object {
lateinit var bot: JDA lateinit var bot: JDA
internal fun getChannel(guildId: Long, channelId: Long): TextChannel? = bot.getGuildById(guildId)?.getTextChannelById(channelId) internal fun getChannel(guildId: Number, channelId: Number): TextChannel? {
return bot.getGuildById(guildId.toLong())?.getTextChannelById(channelId.toLong())
}
fun sendDiscord(user: User, status: IData<IStreamInfo?>) { fun sendDiscord(user: User, status: IData<IStreamInfo?>) {
if(status.content == null) return if(status.content == null) return
if(user.liveAlertMessage != "" && user.liveAlertGuild != null && user.liveAlertChannel != null) { if(user.liveAlertMessage != null && user.liveAlertGuild != null && user.liveAlertChannel != null) {
val channel = getChannel(user.liveAlertGuild!!, user.liveAlertChannel!!) ?: throw RuntimeException("${user.liveAlertChannel} is not valid.") val channel = getChannel(user.liveAlertGuild ?: 0, user.liveAlertChannel ?: 0)
?: throw RuntimeException("${user.liveAlertChannel} is not valid.")
val embed = EmbedBuilder() val embed = EmbedBuilder()
embed.setTitle(status.content!!.liveTitle, "https://chzzk.naver.com/live/${user.token}") embed.setTitle(status.content!!.liveTitle, "https://chzzk.naver.com/live/${user.token}")