public async Task GetServerStatus([Summary("Server id.")] string id) { await ReplyAsync("Updating server status..."); try { var status = await _server.SendStatusRequestAsync(id); id = id.ToUpper(); if (status.Error) { await ReplyAsync($"{id} error: {status.ErrorMessage}"); } else if (status.IsUpdating) { await ReplyAsync($"{id} is updating. Check last update log with command \"``server buildlog {id.ToLower()}``\""); } else if (status.IsRunning) { await ReplyAsync($"{id} is running.\n" + $"Players: {status.Players}\n" + $"Admins: {status.Admins}\n" + $"Join now: {status.Address}:{status.Port}"); } else { await ReplyAsync($"{id} is offline"); } } catch (HttpException e) { await ReplyAsync($"Got exception: ${e.Reason}"); } }
public async Task <ServerStatusResult> StartUpdatingAsync(string id, IMessageChannel updateChannel) { bool updating = _statuses.ContainsKey(id); if (updating) { return(new ServerStatusResult() { ErrorMessage = "Server status is already updating.", Error = true }); } var serverStatus = await _requester.SendStatusRequestAsync(id); if (serverStatus.Error) { return(serverStatus); } var msg = await updateChannel.SendMessageAsync("Updating server status..."); var status = new Status() { LastUpdateTime = DateTime.Now, ServerId = id, StatusResult = serverStatus, Message = msg }; _statuses[id] = status; return(new ServerStatusResult { Message = "Started server status updating." }); }