private FlashServerInfo GetFlashServerInfo() { var newStatus = "Offline"; var status = new ServerStatus(); try { status = _glr.GetServerStatus().GetAwaiter().GetResult(); if (status.Ready) { newStatus = "Online"; } else { newStatus = "Launching"; } } catch (Exception exc) { newStatus = "Offline"; } return(new FlashServerInfo { ServerStatus = newStatus, OnlinePlayers = status.OnlinePlayers, TotalCommandsExecuted = status.TotalCommandsExecuted }); }
public async Task DisplayServerStatusAsync() { ServerStatus status = null; try { status = await _client.GetServerStatus(); } catch (TaskCanceledException e) { await ReplyAsync("Request timed out, servers are off."); return; } if (!status.Ready) { await ReplyAsync($"Servers have been launching for **{(DateTime.UtcNow - status.OnlineSince).Humanize()}**"); return; } var embed = new EmbedBuilder() { Title = $"GLR Server Status", Description = $"Servers have been **online** since **{status.OnlineSince.ToString()}** (miracle innit)", Color = Color.Blue } .AddField("Total Commands Executed", FormatNumbers(status.TotalCommandsExecuted), true) .AddField("Commands Executed", FormatNumbers(status.CommandsExecutedSinceLaunch), true) .AddField("Total Stars", status.TotalStars, false) .AddField("Total Players", status.TotalPlayers, true) .AddField("Online Players", status.OnlinePlayers, true); await ReplyAsync("", false, embed.Build()); }