fix: fix db bug
This commit is contained in:
7 files changed
+49
-38
No files matched your search
@@ -14,16 +14,6 @@ import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
|
||||
|
||||
private suspend fun getUserInfo(listener: OneBotListener, groupId: Long, userId: Long): String {
|
||||
try {
|
||||
val info = listener.getGroupMemberInfo(groupId, userId)
|
||||
return info.card ?: info.nickname
|
||||
} catch (_: NullPointerException) {
|
||||
return userId.toString()
|
||||
}
|
||||
}
|
||||
|
||||
class NiuziRankCommand : BaseCommand() {
|
||||
override val commandNames = listOf("牛子排行榜")
|
||||
|
||||
@@ -31,8 +21,7 @@ class NiuziRankCommand : BaseCommand() {
|
||||
val allNiuzi = niuziManager.getAllNiuzi().sortedBy { it.length }.reversed()
|
||||
val msg = MessageChain.Builder().addText("牛子长度排行榜如下").addNewLine()
|
||||
allNiuzi.forEach {
|
||||
val userName = getUserInfo(listener, message.groupId, it.userId)
|
||||
msg.addText("[$userName] | ${it.length}cm").addNewLine()
|
||||
msg.addText("[${it.nickname}] | ${it.length}cm").addNewLine()
|
||||
}
|
||||
message.reply(msg.build())
|
||||
}
|
||||
@@ -46,8 +35,7 @@ class NiuziBankRankCommand : BaseCommand() {
|
||||
.sortedBy { it.balance }.reversed()
|
||||
val msg = MessageChain.Builder().addText("牛子银行富豪榜排行如下").addNewLine()
|
||||
allNiuziBankAccounts.forEach {
|
||||
val userName = getUserInfo(listener, message.groupId, it.userId)
|
||||
msg.addText("[$userName] | ${it.balance}cm").addNewLine()
|
||||
msg.addText("[${it.nickname}] | ${it.balance}cm").addNewLine()
|
||||
}
|
||||
message.reply(msg.build())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user