public async Task BotInfo() { var proc = System.Diagnostics.Process.GetCurrentProcess(); DiscordSocketClient _client = Context.Client as DiscordSocketClient; Func <double, double> formatRamValue = d => { while (d > 1024) { d /= 1024; } return(d); }; Func <long, string> formatRamUnit = d => { var units = new string[] { "B", "kB", "mB", "gB" }; var unitCount = 0; while (d > 1024) { d /= 1024; unitCount++; } return(units[unitCount]); }; double VSZ = 0; double RSS = 0; try { if (File.Exists($"/proc/{proc.Id}/statm")) { var ramusageInitial = File.ReadAllText($"/proc/{proc.Id}/statm"); var ramusage = ramusageInitial.Split(' ')[0]; VSZ = double.Parse(ramusage); VSZ = VSZ * 4096 / 1048576; ramusage = ramusageInitial.Split(' ')[1]; RSS = double.Parse(ramusage); RSS = RSS * 4096 / 1048576; } } catch (Exception e) { Console.WriteLine(e); await SentryService.SendError(e, Context); } var ebn = new EmbedBuilder() { Color = new Color(4, 97, 247), ThumbnailUrl = (Context.Client.CurrentUser.GetAvatarUrl()), Footer = new EmbedFooterBuilder() { Text = $"Requested by {Context.User.Username}#{Context.User.Discriminator}", IconUrl = (Context.User.GetAvatarUrl()) }, Title = "**Sora Info**", Url = ("http://git.argus.moe/serenity/SoraBot") }; ebn.AddField((x) => { x.Name = "Uptime"; x.IsInline = true; x.Value = (DateTime.Now - proc.StartTime).ToString(@"d'd 'hh\:mm\:ss"); }); ebn.AddField((x) => { x.Name = ".NET Framework"; x.IsInline = true; x.Value = RuntimeInformation.FrameworkDescription; }); ebn.AddField((x) => { x.Name = "Used RAM"; x.IsInline = true; x.Value = $"{(proc.PagedMemorySize64 == 0 ? $"{RSS.ToString("f1")} mB / {VSZ.ToString("f1")} mB" : $"{formatRamValue(proc.PagedMemorySize64).ToString("f2")} {formatRamUnit(proc.PagedMemorySize64)} / {formatRamValue(proc.VirtualMemorySize64).ToString("f2")} {formatRamUnit(proc.VirtualMemorySize64)}")}"; }); ebn.AddField((x) => { x.Name = "Commands Executed"; x.IsInline = true; x.Value = $"{_commandHandler.CommandsRunSinceRestart()} since restart"; }); ebn.AddField((x) => { x.Name = "Threads running"; x.IsInline = true; x.Value = $"{((IEnumerable)proc.Threads).OfType<ProcessThread>().Where(t=>t.ThreadState == ThreadState.Running).Count()} / {proc.Threads.Count}"; }); ebn.AddField((x) => { x.Name = "Connected Guilds"; x.IsInline = true; x.Value = $"{_client.Guilds.Count}"; }); var channelCount = 0; var userCount = 0; foreach (var g in _client.Guilds) { channelCount += g.Channels.Count; userCount += g.MemberCount; } ebn.AddField((x) => { x.Name = "Watching Channels"; x.IsInline = true; x.Value = $"{channelCount}"; }); ebn.AddField((x) => { x.Name = "Users with access"; x.IsInline = true; x.Value = $"{userCount}"; }); ebn.AddField((x) => { x.Name = "Playing music for"; x.IsInline = true; x.Value = $"{musicService.PlayingFor()} guilds"; }); ebn.AddField((x) => { x.Name = "Ping"; x.IsInline = true; x.Value = $"{_client.Latency} ms"; }); ebn.AddField((x) => { x.Name = "Sora's Official Guild"; x.IsInline = true; x.Value = $"[Feedback and Suggestions here](https://discord.gg/Pah4yj5)"; }); await Context.Channel.SendMessageAsync("", false, ebn); }