From d323bf28db0606f8c4d7866871f0506f2be55e3d Mon Sep 17 00:00:00 2001 From: dalbodeule <11470513+dalbodeule@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:43:02 +0900 Subject: [PATCH] some changes on Connector, RegisterCommand --- .../chatbot/discord/commands/RegisterCommand.kt | 8 +++++++- .../kotlin/space/mori/chzzk_bot/common/Connector.kt | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/commands/RegisterCommand.kt b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/commands/RegisterCommand.kt index cabe38d..58f1009 100644 --- a/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/commands/RegisterCommand.kt +++ b/chatbot/src/main/kotlin/space/mori/chzzk_bot/chatbot/discord/commands/RegisterCommand.kt @@ -1,5 +1,8 @@ package space.mori.chzzk_bot.chatbot.discord.commands +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import net.dv8tion.jda.api.JDA import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent import net.dv8tion.jda.api.interactions.commands.OptionType @@ -38,9 +41,12 @@ object RegisterCommand: CommandInterface { } try { + val user = UserService.saveUser(chzzkChannel.channelName, chzzkChannel.channelId, event.user.idLong) + CoroutineScope(Dispatchers.Main).launch { + ChzzkHandler.addUser(chzzkChannel, user) + } event.hook.sendMessage("등록이 완료되었습니다. `${chzzkChannel.channelId}` - `${chzzkChannel.channelName}`") - ChzzkHandler.addUser(chzzkChannel, user) } catch(e: Exception) { event.hook.sendMessage("에러가 발생했습니다.").queue() logger.debug(e.stackTraceToString()) diff --git a/common/src/main/kotlin/space/mori/chzzk_bot/common/Connector.kt b/common/src/main/kotlin/space/mori/chzzk_bot/common/Connector.kt index 8f8f7d3..6e72289 100644 --- a/common/src/main/kotlin/space/mori/chzzk_bot/common/Connector.kt +++ b/common/src/main/kotlin/space/mori/chzzk_bot/common/Connector.kt @@ -24,7 +24,15 @@ object Connector { init { Database.connect(dataSource) - val tables = listOf(Users, Commands, Counters, DailyCounters, PersonalCounters, Managers) + val tables = listOf( + Users, + Commands, + Counters, + DailyCounters, + PersonalCounters, + Managers, + TimerConfigs + ) transaction { SchemaUtils.createMissingTablesAndColumns(* tables.toTypedArray())