From 39d0c3f0aafd19388e44c72a8841c757f435d1a2 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 12 May 2019 22:32:44 -0400 Subject: Started working on uptime and added a package --- AleeBot/AleeBot.csproj | 6 ++++-- AleeBot/Modules/Uptime.cs | 16 ++++++++++++++-- AleeBot/Program.cs | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'AleeBot') diff --git a/AleeBot/AleeBot.csproj b/AleeBot/AleeBot.csproj index 1c9108d..1997e7a 100644 --- a/AleeBot/AleeBot.csproj +++ b/AleeBot/AleeBot.csproj @@ -3,9 +3,9 @@ Exe netcoreapp3.0 - 3.0.0 + 3.1.0 Andrew Lee - (C) Copyright 2019 + (C) Copyright 2015-2019 en AleeCorp AleeBot.ico @@ -13,10 +13,12 @@ AleeBot https://github.com/AleeCorp/AleeBot.NET false + false + diff --git a/AleeBot/Modules/Uptime.cs b/AleeBot/Modules/Uptime.cs index 410d544..502cca9 100644 --- a/AleeBot/Modules/Uptime.cs +++ b/AleeBot/Modules/Uptime.cs @@ -17,6 +17,8 @@ * along with this program. If not, see . * **********************************************/ +using System; +using System.Diagnostics; using Discord; using Discord.Commands; using System.Threading.Tasks; @@ -31,9 +33,19 @@ namespace AleeBot.Modules var embed = new EmbedBuilder(); embed.WithTitle("AleeBot Uptime"); embed.WithColor(Color.Green); - embed.AddField("System Uptime", "Coming Soon!"); + embed.AddField("System Uptime", SysUptime()); embed.AddField("Bot Uptime", "Coming Soon!"); await Context.Channel.SendMessageAsync(embed: embed.Build()); - } + } + + public TimeSpan SysUptime() + { + using (var uptime = new PerformanceCounter("System", "System Up Time")) + { + uptime.NextValue(); + return TimeSpan.FromSeconds(uptime.NextValue()); + } + + } } } diff --git a/AleeBot/Program.cs b/AleeBot/Program.cs index c6d10f4..54cd816 100644 --- a/AleeBot/Program.cs +++ b/AleeBot/Program.cs @@ -45,6 +45,7 @@ namespace AleeBot else { Console.WriteLine("[ERROR] token.txt isn't found."); + Console.ReadKey(); Environment.Exit(0); } } @@ -69,7 +70,6 @@ namespace AleeBot _client.Ready += () => { Console.WriteLine($"[SUCCESS] AleeBot {Data.Version} is now ready!"); - return Task.CompletedTask; }; -- cgit v1.2.3