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())