Skip to content

Commit

Permalink
feat: Made /server player online able to query all servers
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed Dec 8, 2023
1 parent b06063e commit cdb759c
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ class ServerCommand(instances: InstanceManager) : ImperiumApplication.Listener {

@Command(["server", "player", "online"])
@NonEphemeral
suspend fun onServerPlayerOnline(actor: InteractionSender, server: String) {
val online = tracker.getOnlinePlayers(server)
suspend fun onServerPlayerOnline(actor: InteractionSender, server: String? = null) {
val online =
if (server != null) {
tracker.getOnlinePlayers(server)
} else {
discovery.servers.flatMap { (name, server) ->
if (server.data is Discovery.Data.Mindustry)
tracker.getOnlinePlayers(name) ?: emptyList()
else emptyList()
}
}
if (online == null) {
actor.respond("Server not found.")
return
Expand Down

0 comments on commit cdb759c

Please sign in to comment.