diff --git a/src/main/kotlin/org/openredstone/chad/commands/Command.kt b/src/main/kotlin/org/openredstone/chad/commands/Command.kt index ee00c8e..ec0d810 100644 --- a/src/main/kotlin/org/openredstone/chad/commands/Command.kt +++ b/src/main/kotlin/org/openredstone/chad/commands/Command.kt @@ -410,29 +410,22 @@ fun piklCommand(authorizedRoles: List, discordServer: Server, discordApi } fun historyCommand(authorizedRoles: List, sql: Sql) = command(authorizedRoles) { - fun timestampToString(timestamp: Int): String { - val instant = Instant.ofEpochSecond(timestamp.toLong()) - val dateTime = LocalDateTime.ofInstant(instant, ZoneOffset.UTC) - return dateTime.format(DateTimeFormatter.ISO_DATE_TIME) - } - - data class HistoryContainer(val key: String, var count: Int, var lastRan: String) + data class HistoryContainer(val key: String, var count: Int, var lastRan: Int) val time by optional() reply(isPrivate = true) { val historyMap = mutableMapOf() sql.getHistory().forEach { - val timestamp = timestampToString(it.time) if (it.key in historyMap) { historyMap[it.key]!!.apply { this.count += 1 - this.lastRan = timestamp + this.lastRan = it.time } // The sort order is time ASC, // so newer runs will be later // in the search result } else { - historyMap[it.key] = HistoryContainer(it.key, 1, timestamp) + historyMap[it.key] = HistoryContainer(it.key, 1, it.time) } } historyMap.values @@ -440,7 +433,7 @@ fun historyCommand(authorizedRoles: List, sql: Sql) = command(authorized .take(10).joinToString( prefix = "Query results less than $time seconds:\n", separator = "\n" ) { - "${it.count}: ${it.key}, last ran ${it.lastRan}" + "${it.count}: ${it.key}, last ran " } } }