some changes on Connector, RegisterCommand

This commit is contained in:
dalbodeule 2024-08-03 21:43:02 +09:00
parent b3da9db627
commit d323bf28db
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65
2 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,8 @@
package space.mori.chzzk_bot.chatbot.discord.commands 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.JDA
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.interactions.commands.OptionType import net.dv8tion.jda.api.interactions.commands.OptionType
@ -38,9 +41,12 @@ object RegisterCommand: CommandInterface {
} }
try { try {
val user = UserService.saveUser(chzzkChannel.channelName, chzzkChannel.channelId, event.user.idLong) 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}`") event.hook.sendMessage("등록이 완료되었습니다. `${chzzkChannel.channelId}` - `${chzzkChannel.channelName}`")
ChzzkHandler.addUser(chzzkChannel, user)
} catch(e: Exception) { } catch(e: Exception) {
event.hook.sendMessage("에러가 발생했습니다.").queue() event.hook.sendMessage("에러가 발생했습니다.").queue()
logger.debug(e.stackTraceToString()) logger.debug(e.stackTraceToString())

View File

@ -24,7 +24,15 @@ object Connector {
init { init {
Database.connect(dataSource) Database.connect(dataSource)
val tables = listOf(Users, Commands, Counters, DailyCounters, PersonalCounters, Managers) val tables = listOf(
Users,
Commands,
Counters,
DailyCounters,
PersonalCounters,
Managers,
TimerConfigs
)
transaction { transaction {
SchemaUtils.createMissingTablesAndColumns(* tables.toTypedArray()) SchemaUtils.createMissingTablesAndColumns(* tables.toTypedArray())