fix(bot): 修复因机器人命令列表为空而导致命令列表自动更新报错的问题.

当机器人因扩展加载失败时, 将无法正常执行命令更新操作, 故添加空命令检查以避免该问题.
This commit is contained in:
LamGC 2022-05-17 19:56:42 +08:00
parent 6e59a9a5ac
commit ef37f3b2d7
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -103,6 +103,12 @@ internal class ScalaBot(
} }
BotCommand(it.name(), abilityInfo) BotCommand(it.name(), abilityInfo)
} }
if (botCommands.isEmpty()) {
log.info { "Bot 没有任何命令, 命令列表更新已跳过." }
return true
}
val setMyCommands = SetMyCommands() val setMyCommands = SetMyCommands()
setMyCommands.commands = botCommands setMyCommands.commands = botCommands
return execute(DeleteMyCommands()) && execute(setMyCommands) return execute(DeleteMyCommands()) && execute(setMyCommands)