From 81677ee761b70124a6733917ead3be4383efea6d Mon Sep 17 00:00:00 2001 From: Toastie <toastie@toastiet0ast.com> Date: Mon, 24 Feb 2025 13:30:26 +1300 Subject: [PATCH] Added '--version' which outputs the bot's version using '--version' during bot execution outputs the bot's version modify how app version is retrieved modify casing of 'unknown' version --- src/EllieBot/Program.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/EllieBot/Program.cs b/src/EllieBot/Program.cs index f0e553b..bb49ad9 100644 --- a/src/EllieBot/Program.cs +++ b/src/EllieBot/Program.cs @@ -1,4 +1,17 @@ -var shardId = 0; +using System.Reflection; + +static string GetAppVersion() +{ + return Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown"; +} + +if (args.Length > 0 && args[0] == "--version") +{ + Console.WriteLine(GetAppVersion()); + return; +} + +var shardId = 0; int? totalShards = null; // 0 to read from creds.yml if (args.Length > 0 && args[0] != "run") { @@ -20,5 +33,4 @@ if (args.Length > 0 && args[0] != "run") } } - await new Bot(shardId, totalShards).RunAndBlockAsync(); \ No newline at end of file