fix User.kt

- set "discord", "token" row to nullable.
This commit is contained in:
dalbodeule
2024-08-08 20:18:49 +09:00
parent 80fa2d5029
commit f2a871d664
10 changed files with 26 additions and 22 deletions

View File

@@ -29,7 +29,7 @@ object ChzzkHandler {
private val logger = LoggerFactory.getLogger(this::class.java)
lateinit var botUid: String
@Volatile private var running: Boolean = false
val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
fun addUser(chzzkChannel: ChzzkChannel, user: User) {
handlers.add(UserHandler(chzzkChannel, logger, user, streamStartTime = null))

View File

@@ -157,7 +157,7 @@ class MessageHandler(
CoroutineScope(Dispatchers.Default).launch {
dispatcher.post(
TimerEvent(
user.token,
user.token!!,
TimerType.UPTIME,
getUptime(handler.streamStartTime!!)
)
@@ -167,7 +167,7 @@ class MessageHandler(
"삭제" -> {
logger.debug("${user.token} / 삭제")
CoroutineScope(Dispatchers.Default).launch {
dispatcher.post(TimerEvent(user.token, TimerType.REMOVE, ""))
dispatcher.post(TimerEvent(user.token!!, TimerType.REMOVE, ""))
}
}
"설정" -> {
@@ -191,7 +191,7 @@ class MessageHandler(
val timestamp = currentTime.plus(time.toLong(), ChronoUnit.MINUTES)
CoroutineScope(Dispatchers.Default).launch {
dispatcher.post(TimerEvent(user.token, TimerType.TIMER, timestamp.toString()))
dispatcher.post(TimerEvent(user.token!!, TimerType.TIMER, timestamp.toString()))
}
} catch (e: NumberFormatException) {
listener.sendChat("!타이머/숫자 형식으로 적어주세요! 단위: 분")
@@ -254,7 +254,7 @@ class MessageHandler(
CoroutineScope(Dispatchers.Default).launch {
dispatcher.post(
SongEvent(
user.token,
user.token!!,
SongType.ADD,
msg.userId,
msg.profile?.nickname ?: "",
@@ -286,10 +286,12 @@ class MessageHandler(
val session = "${UUID.randomUUID()}${UUID.randomUUID()}".replace("-", "")
bot.retrieveUserById(user.discord).queue { discordUser ->
discordUser?.openPrivateChannel()?.queue { channel ->
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
.queue()
user.discord?.let {
bot.retrieveUserById(it).queue { discordUser ->
discordUser?.openPrivateChannel()?.queue { channel ->
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
.queue()
}
}
}
}

View File

@@ -57,7 +57,7 @@ object AddCommand : CommandInterface {
return
}
val chzzkChannel = Connector.getChannel(user!!.token)
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
try {
CommandService.saveCommand(user!!, label, content, failContent ?: "")

View File

@@ -43,7 +43,7 @@ object AlertCommand : CommandInterface {
return
}
val chzzkChannel = Connector.getChannel(user!!.token)
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
try {
val newUser = UserService.updateLiveAlert(user!!.id.value, channel?.guild?.idLong ?: 0L, channel?.idLong ?: 0L, content ?: "")

View File

@@ -47,7 +47,7 @@ object RemoveCommand : CommandInterface {
return
}
val chzzkChannel = Connector.getChannel(user!!.token)
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
try {
CommandService.removeCommand(user!!, label)

View File

@@ -51,7 +51,7 @@ object UpdateCommand : CommandInterface {
return
}
val chzzkChannel = Connector.getChannel(user!!.token)
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
try {
CommandService.updateCommand(user!!, label, content, failContent ?: "")