diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/MCPingCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/MCPingCommand.kt index 57a5cb6..d1d4129 100644 --- a/src/main/kotlin/cn/rtast/fancybot/commands/MCPingCommand.kt +++ b/src/main/kotlin/cn/rtast/fancybot/commands/MCPingCommand.kt @@ -45,17 +45,14 @@ class MCPingCommand : BaseCommand() { try { val rawResponse = pingInstance.pingServer(host, port) val jsonResponse = rawResponse?.fromJson()!! - val msg = MessageChain.Builder() - .addAt(message.sender.userId) - .addNewLine() - .addImage(jsonResponse.favicon, true) - .addText("服务器地址: $host:$port") - .addNewLine() - .addText("协议版本号: ${jsonResponse.version.protocol}/${jsonResponse.version.name}") - .addNewLine() - .addText("玩家: ${jsonResponse.players.online}/${jsonResponse.players.max}") - .build() - listener.sendGroupMessage(message.groupId, msg) + val msg = MessageChain.Builder().addAt(message.sender.userId).addNewLine() + if (jsonResponse.favicon != null) msg.addImage(jsonResponse.favicon, true) + msg.addText("服务器地址: $host:$port") + msg.addNewLine() + msg.addText("协议版本号: ${jsonResponse.version.protocol}/${jsonResponse.version.name}") + msg.addNewLine() + msg.addText("玩家: ${jsonResponse.players.online}/${jsonResponse.players.max}") + listener.sendGroupMessage(message.groupId, msg.build()) } catch (_: Exception) { val msg = MessageChain.Builder() .addAt(message.sender.userId) diff --git a/src/main/kotlin/cn/rtast/fancybot/entity/MCPingResponse.kt b/src/main/kotlin/cn/rtast/fancybot/entity/MCPingResponse.kt index cefbacb..015073d 100644 --- a/src/main/kotlin/cn/rtast/fancybot/entity/MCPingResponse.kt +++ b/src/main/kotlin/cn/rtast/fancybot/entity/MCPingResponse.kt @@ -10,7 +10,7 @@ package cn.rtast.fancybot.entity data class MCPingResponse( val version: Version, val players: Players, - val favicon: String + val favicon: String? ) { data class Version( val protocol: Int,