From 35d8759ee3ab9be9e4903bd7eb1994cb715cc822 Mon Sep 17 00:00:00 2001 From: dalbodeule <11470513+dalbodeule@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:32:31 +0900 Subject: [PATCH] asdf4 --- .../space/mori/chzzk_bot/chatbot/chzzk/ChzzkHandler.kt | 2 ++ .../space/mori/chzzk_bot/chatbot/discord/Discord.kt | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/ChzzkHandler.kt b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/ChzzkHandler.kt index 5d1846d..c7aa31e 100644 --- a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/ChzzkHandler.kt +++ b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/chzzk/ChzzkHandler.kt @@ -239,6 +239,8 @@ class UserHandler( CoroutineScope(Dispatchers.Default).launch { logger.info("${user.username} is live.") + reloadUser(UserService.getUser(user.id.value)!!) + logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}") listener.connectAsync().await() diff --git a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/Discord.kt b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/Discord.kt index ea1431f..4214fbb 100644 --- a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/Discord.kt +++ b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/Discord.kt @@ -31,12 +31,15 @@ class Discord: ListenerAdapter() { companion object { 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) { if(status.content == null) return - if(user.liveAlertMessage != "" && user.liveAlertGuild != null && user.liveAlertChannel != null) { - val channel = getChannel(user.liveAlertGuild!!, user.liveAlertChannel!!) ?: throw RuntimeException("${user.liveAlertChannel} is not valid.") + if(user.liveAlertMessage != null && user.liveAlertGuild != null && user.liveAlertChannel != null) { + val channel = getChannel(user.liveAlertGuild ?: 0, user.liveAlertChannel ?: 0) + ?: throw RuntimeException("${user.liveAlertChannel} is not valid.") val embed = EmbedBuilder() embed.setTitle(status.content!!.liveTitle, "https://chzzk.naver.com/live/${user.token}")