diff --git a/AzzyBot/Customization/Core/StringsCore.json b/AzzyBot/Customization/Core/StringsCore.json
index 523a93f9..b3eb67d1 100644
--- a/AzzyBot/Customization/Core/StringsCore.json
+++ b/AzzyBot/Customization/Core/StringsCore.json
@@ -18,13 +18,14 @@
"EmbedAzzyStats15MinLoadTitle": "15-Min-Load",
"EmbedAzzyStats15MinLoadDesc": "**%VALUE%**",
"EmbedAzzyStatsRamUsageTitle": "RAM usage",
- "EmbedAzzyStatsRamUsageDesc": "Used: **%USED%** GB\nAzzyBot: **%BOT%** GB\nTotal: **%TOTAL%** GB",
+ "EmbedAzzyStatsRamUsageDesc": "Used: **%USED%** GB\nTotal: **%TOTAL%** GB",
+ "EmbedAzzyStatsRamUsageAzzyTitle": "AzzyBot RAM usage",
+ "EmbedAzzyStatsRamUsageAzzyDesc": "**%BOT%** GB",
"EmbedAzzyStatsDiskUsageTitle": "Disk usage",
"EmbedAzzyStatsDiskUsageDesc": "Used: **%USED%** GB\nTotal: **%TOTAL%** GB",
"EmbedAzzyStatsNetworkUsageTitle": "Network \"%NAME%\"",
"EmbedAzzyStatsNetworkUsageDesc": "Receive: **%RECEIVE%** KB/s\nTransmit: **%TRANSMIT%** KB/s",
- "EmbedAzzyStatsNotAvailableTitle": "Command Not Available",
- "EmbedAzzyStatsNotAvailableDesc": "This command is not available on non-Linux systems!",
+ "EmbedAzzyStatsMoreStats": "More stats are only available on linux systems.",
"EmbedAzzyInfoTitle": "Azzy Information",
"EmbedAzzyInfoBotUptime": "Bot Uptime",
"EmbedAzzyInfoBotName": "Name",
diff --git a/AzzyBot/Modules/Core/CoreAzzyStatsGeneral.cs b/AzzyBot/Modules/Core/CoreAzzyStatsGeneral.cs
new file mode 100644
index 00000000..8fd8a503
--- /dev/null
+++ b/AzzyBot/Modules/Core/CoreAzzyStatsGeneral.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Threading.Tasks;
+using AzzyBot.ExceptionHandling;
+using AzzyBot.Settings;
+using AzzyBot.Strings.Core;
+using Microsoft.Extensions.Logging;
+
+namespace AzzyBot.Modules.Core;
+
+///
+/// Contains methods for getting general information of the bot.
+///
+internal static class CoreAzzyStatsGeneral
+{
+ ///
+ /// Gets the disk usage of the server.
+ ///
+ /// A string representing the disk usage in GB.
+ internal static string GetDiskUsage()
+ {
+ try
+ {
+ string diskUsage = string.Empty;
+
+ foreach (DriveInfo drive in DriveInfo.GetDrives())
+ {
+ if (drive.IsReady && drive.Name == "/")
+ {
+ double totalSizeGB = drive.TotalSize / (1024.0 * 1024.0 * 1024.0);
+ double freeSpaceGB = drive.TotalFreeSpace / (1024.0 * 1024.0 * 1024.0);
+ double usedSpaceGB = totalSizeGB - freeSpaceGB;
+
+ return CoreStringBuilder.GetEmbedAzzyStatsDiskUsageDesc(Math.Round(usedSpaceGB, 2), Math.Round(totalSizeGB, 2));
+ }
+ }
+
+ return diskUsage;
+ }
+ catch (DriveNotFoundException)
+ {
+ ExceptionHandler.LogMessage(LogLevel.Error, "Main drive not found");
+ throw;
+ }
+ }
+
+ internal static long GetSystemUptime()
+ {
+ TimeSpan uptime = new(Environment.TickCount64);
+ DateTime dateTime = DateTime.Now.AddMinutes(-uptime.Minutes);
+
+ return CoreMisc.ConvertToUnixTime(dateTime);
+ }
+
+ internal static string GetActivatedModules()
+ {
+ string text = "- Core";
+
+ if (BaseSettings.ActivateAzuraCast)
+ text += "\n- AzuraCast";
+
+ if (BaseSettings.ActivateClubManagement)
+ text += "\n- ClubManagement";
+
+ if (BaseSettings.ActivateMusicStreaming)
+ text += "\n- MusicStreaming";
+
+ return text;
+ }
+
+ internal static string GetBotName => Assembly.GetExecutingAssembly().GetName().Name ?? "Bot name not found";
+
+ ///
+ /// Gets the memory usage only of the bot itself.
+ ///
+ /// The memory usage of the bot in GB.
+ internal static double GetBotMemoryUsage()
+ {
+ Process? process = Process.GetCurrentProcess();
+ double usedMemoryGB = process.WorkingSet64 / (1024.0 * 1024.0 * 1024.0);
+
+ process.Dispose();
+
+ return Math.Round(usedMemoryGB, 2);
+ }
+
+ internal static string GetBotUptime()
+ {
+ using Process azzy = Process.GetCurrentProcess();
+
+ return $"";
+ }
+
+ internal static string GetBotEnvironment => (Program.GetDiscordClientId == 1217214768159653978) ? "Development" : "Production";
+ internal static string GetBotVersion => Assembly.GetExecutingAssembly().GetName().Version?.ToString(3) ?? "Azzy version not found";
+
+ internal static async Task GetBotCommitAsync()
+ {
+ if (CoreModule.CommitLock is null)
+ return "Commit not found";
+
+ string commit = await CoreModule.CommitLock.GetFileContentAsync();
+ if (string.IsNullOrWhiteSpace(commit))
+ commit = "Commit not found";
+
+ return commit;
+ }
+
+ internal static async Task GetBotCompileDateAsync()
+ {
+ if (CoreModule.BuildTimeLock is null)
+ return "CompileDate not found";
+
+ if (!DateTime.TryParse(await CoreModule.BuildTimeLock.GetFileContentAsync(), out DateTime dateTime))
+ return "CompileDate not found";
+
+ return $"";
+ }
+
+ internal static string GetDotNetVersion => Environment.Version.ToString() ?? ".NET version not found";
+ internal static string GetDSharpNetVersion => Program.GetDiscordClientVersion;
+}
diff --git a/AzzyBot/Modules/Core/CoreAzzyStats.cs b/AzzyBot/Modules/Core/CoreAzzyStatsLinux.cs
similarity index 72%
rename from AzzyBot/Modules/Core/CoreAzzyStats.cs
rename to AzzyBot/Modules/Core/CoreAzzyStatsLinux.cs
index 9bd11e15..0b82592b 100644
--- a/AzzyBot/Modules/Core/CoreAzzyStats.cs
+++ b/AzzyBot/Modules/Core/CoreAzzyStatsLinux.cs
@@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Globalization;
using System.IO;
-using System.Reflection;
using System.Threading.Tasks;
using AzzyBot.ExceptionHandling;
using AzzyBot.Modules.Core.Structs;
-using AzzyBot.Settings;
-using AzzyBot.Strings.Core;
using Microsoft.Extensions.Logging;
namespace AzzyBot.Modules.Core;
///
-/// Contains methods for getting the CPU usage of the server.
+/// Contains methods for getting stats of the server on linux OS.
///
-internal static class ServerCpuUsage
+internal static class CoreAzzyStatsLinux
{
///
/// Gets the CPU usage of each core on the server.
@@ -158,13 +154,7 @@ internal static async Task GetCpuLoadAsync()
throw;
}
}
-}
-///
-/// Contains methods for getting the memory usage of the server.
-///
-internal static class ServerMemoryUsage
-{
///
/// Gets the total and used memory of the server.
///
@@ -223,70 +213,7 @@ static long ParseValue(string line)
throw;
}
}
-}
-///
-/// Contains methods for getting the memory usage only of the bot itself.
-///
-internal static class BotMemoryUsage
-{
- ///
- /// Gets the memory usage only of the bot itself.
- ///
- /// The memory usage of the bot in GB.
- internal static double GetMemoryUsage()
- {
- Process? process = Process.GetCurrentProcess();
- double usedMemoryGB = process.WorkingSet64 / (1024.0 * 1024.0 * 1024.0);
-
- process.Dispose();
-
- return Math.Round(usedMemoryGB, 2);
- }
-}
-
-///
-/// Contains methods for getting the disk usage of the server.
-///
-internal static class ServerDiskUsage
-{
- ///
- /// Gets the disk usage of the server.
- ///
- /// A string representing the disk usage in GB.
- internal static string GetDiskUsage()
- {
- try
- {
- string diskUsage = string.Empty;
-
- foreach (DriveInfo drive in DriveInfo.GetDrives())
- {
- if (drive.IsReady && drive.Name == "/")
- {
- double totalSizeGB = drive.TotalSize / (1024.0 * 1024.0 * 1024.0);
- double freeSpaceGB = drive.TotalFreeSpace / (1024.0 * 1024.0 * 1024.0);
- double usedSpaceGB = totalSizeGB - freeSpaceGB;
-
- return CoreStringBuilder.GetEmbedAzzyStatsDiskUsageDesc(Math.Round(usedSpaceGB, 2), Math.Round(totalSizeGB, 2));
- }
- }
-
- return diskUsage;
- }
- catch (DriveNotFoundException)
- {
- ExceptionHandler.LogMessage(LogLevel.Error, "Main drive not found");
- throw;
- }
- }
-}
-
-///
-/// Contains methods for getting the network usage of the server.
-///
-internal static class ServerNetworkUsage
-{
///
/// Gets the network usage of the server.
///
@@ -358,13 +285,7 @@ private static async Task> ReadNetworkSta
throw;
}
}
-}
-///
-/// Contains methods for getting information about the server.
-///
-internal static class ServerInfo
-{
///
/// Gets the system uptime of the server.
///
@@ -396,64 +317,3 @@ internal static async Task GetSystemUptimeAsync()
}
}
}
-
-///
-/// Contains methods for getting information about the bot.
-///
-internal static class BotInfo
-{
- private static DateTime StartTime = DateTime.MinValue;
-
- ///
- /// Sets the start time of the bot.
- ///
- internal static void SetStartTime()
- {
- if (StartTime == DateTime.MinValue)
- StartTime = DateTime.Now;
- }
-
- internal static string GetActivatedModules()
- {
- string text = "- Core";
-
- if (BaseSettings.ActivateAzuraCast)
- text += "\n- AzuraCast";
-
- if (BaseSettings.ActivateClubManagement)
- text += "\n- ClubManagement";
-
- return text;
- }
-
- internal static string GetBotName => Assembly.GetExecutingAssembly().GetName().Name ?? "Bot name not found";
- internal static string GetBotUptime => (CoreMisc.CheckIfLinuxOs()) ? $"" : "This feature is not available on Windows";
- internal static string GetBotEnvironment => (Program.GetDiscordClientId == 1169381408939192361) ? "Development" : "Production";
- internal static string GetBotVersion => Assembly.GetExecutingAssembly().GetName().Version?.ToString(3) ?? "Azzy version not found";
-
- internal static async Task GetBotCommitAsync()
- {
- if (CoreModule.CommitLock is null)
- return "Commit not found";
-
- string commit = await CoreModule.CommitLock.GetFileContentAsync();
- if (string.IsNullOrWhiteSpace(commit))
- commit = "Commit not found";
-
- return commit;
- }
-
- internal static async Task GetBotCompileDateAsync()
- {
- if (CoreModule.BuildTimeLock is null)
- return "CompileDate not found";
-
- if (!DateTime.TryParse(await CoreModule.BuildTimeLock.GetFileContentAsync(), out DateTime dateTime))
- return "CompileDate not found";
-
- return $"";
- }
-
- internal static string GetDotNetVersion => Environment.Version.ToString() ?? ".NET version not found";
- internal static string GetDSharpNetVersion => Program.GetDiscordClientVersion;
-}
diff --git a/AzzyBot/Modules/Core/CoreCommands.cs b/AzzyBot/Modules/Core/CoreCommands.cs
index 6ac2c4e3..db923b8f 100644
--- a/AzzyBot/Modules/Core/CoreCommands.cs
+++ b/AzzyBot/Modules/Core/CoreCommands.cs
@@ -73,12 +73,6 @@ internal static async Task CorePingAzzyCommandAsync(InteractionContext ctx)
ExceptionHandler.LogMessage(LogLevel.Debug, "CorePingAzzyCommand requested");
await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource);
- if (!CoreMisc.CheckIfLinuxOs())
- {
- await ctx.EditResponseAsync(new DiscordWebhookBuilder().AddEmbed(CoreEmbedBuilder.BuildAzzyStatsNotAvailableEmbed(ctx.Client.CurrentUser.Username, ctx.Client.CurrentUser.AvatarUrl)));
- return;
- }
-
await ctx.EditResponseAsync(new DiscordWebhookBuilder().AddEmbed(await CoreEmbedBuilder.BuildAzzyStatsEmbedAsync(ctx.Client.CurrentUser.Username, ctx.Client.CurrentUser.AvatarUrl, ctx.Client.Ping)));
}
}
diff --git a/AzzyBot/Modules/Core/CoreEmbedBuilder.cs b/AzzyBot/Modules/Core/CoreEmbedBuilder.cs
index 3cc641b6..770d50ec 100644
--- a/AzzyBot/Modules/Core/CoreEmbedBuilder.cs
+++ b/AzzyBot/Modules/Core/CoreEmbedBuilder.cs
@@ -87,53 +87,58 @@ internal static async Task BuildAzzyStatsEmbedAsync(string userNam
ArgumentException.ThrowIfNullOrWhiteSpace(userName, nameof(userName));
ArgumentException.ThrowIfNullOrWhiteSpace(userAvatarUrl, nameof(userAvatarUrl));
- Dictionary cpuUsage = await ServerCpuUsage.GetCpuUsageAsync();
- long uptime = await ServerInfo.GetSystemUptimeAsync();
+ string title = CoreStringBuilder.GetEmbedAzzyStatsTitle;
+ string footer = string.Empty;
+ long uptime = CoreAzzyStatsGeneral.GetSystemUptime(); // is incorrect on windows systems without administative privileges
string coreUsage = string.Empty;
- string allCoreUsage = string.Empty;
- MemoryUsageStruct memory = await ServerMemoryUsage.GetMemoryUsageAsync();
- double processMem = BotMemoryUsage.GetMemoryUsage();
- string diskUsage = ServerDiskUsage.GetDiskUsage();
- Dictionary networkUsage = await ServerNetworkUsage.GetNetworkUsageAsync();
+ double processMem = CoreAzzyStatsGeneral.GetBotMemoryUsage();
+ string diskUsage = CoreAzzyStatsGeneral.GetDiskUsage();
+ CpuLoadStruct cpuLoad = new();
+ MemoryUsageStruct memory = new();
- foreach (KeyValuePair kvp in cpuUsage)
+ if (CoreMisc.CheckIfLinuxOs())
{
- int counter = kvp.Key;
+ uptime = await CoreAzzyStatsLinux.GetSystemUptimeAsync();
+ string allCoreUsage = string.Empty;
+ Dictionary cpuUsage = await CoreAzzyStatsLinux.GetCpuUsageAsync();
+ memory = await CoreAzzyStatsLinux.GetMemoryUsageAsync();
- if (counter == 0)
- {
- allCoreUsage = CoreStringBuilder.GetEmbedAzzyStatsCpuUsageAll(kvp.Value);
- }
- else
+ foreach (KeyValuePair kvp in cpuUsage)
{
- int core = counter - 1;
- coreUsage += CoreStringBuilder.GetEmbedAzzyStatsCpuUsageCore(core, kvp.Value);
+ int counter = kvp.Key;
+
+ if (counter == 0)
+ {
+ allCoreUsage = CoreStringBuilder.GetEmbedAzzyStatsCpuUsageAll(kvp.Value);
+ }
+ else
+ {
+ int core = counter - 1;
+ coreUsage += CoreStringBuilder.GetEmbedAzzyStatsCpuUsageCore(core, kvp.Value);
+ }
}
- }
- coreUsage += allCoreUsage;
+ coreUsage += allCoreUsage;
+
+ cpuLoad = await CoreAzzyStatsLinux.GetCpuLoadAsync();
+ }
- string title = CoreStringBuilder.GetEmbedAzzyStatsTitle;
- CpuLoadStruct cpuLoad = await ServerCpuUsage.GetCpuLoadAsync();
Dictionary fields = CoreStringBuilder.GetEmbedAzzyStatsFields(uptime, ping, coreUsage, cpuLoad.OneMin, cpuLoad.FiveMin, cpuLoad.FifteenMin, memory.Used, processMem, memory.Total, diskUsage);
- foreach (KeyValuePair kvp in networkUsage)
+ if (CoreMisc.CheckIfLinuxOs())
{
- fields.Add(CoreStringBuilder.GetEmbedAzzyStatsNetworkUsageTitle(kvp.Key), new(kvp.Key, CoreStringBuilder.GetEmbedAzzyStatsNetworkUsageDesc(kvp.Value.Received, kvp.Value.Transmitted), true));
+ Dictionary networkUsage = await CoreAzzyStatsLinux.GetNetworkUsageAsync();
+ foreach (KeyValuePair kvp in networkUsage)
+ {
+ fields.Add(CoreStringBuilder.GetEmbedAzzyStatsNetworkUsageTitle(kvp.Key), new(kvp.Key, CoreStringBuilder.GetEmbedAzzyStatsNetworkUsageDesc(kvp.Value.Received, kvp.Value.Transmitted), true));
+ }
+ }
+ else
+ {
+ footer = CoreStringBuilder.GetEmbedAzzyStatsMoreStats;
}
- return CreateBasicEmbed(title, string.Empty, userName, userAvatarUrl, DiscordColor.Red, userAvatarUrl, string.Empty, fields);
- }
-
- internal static DiscordEmbed BuildAzzyStatsNotAvailableEmbed(string userName, string userAvatarUrl)
- {
- ArgumentException.ThrowIfNullOrWhiteSpace(userName, nameof(userName));
- ArgumentException.ThrowIfNullOrWhiteSpace(userAvatarUrl, nameof(userAvatarUrl));
-
- string title = CoreStringBuilder.GetEmbedAzzyStatsNotAvailableTitle;
- string description = CoreStringBuilder.GetEmbedAzzyStatsNotAvailableDesc;
-
- return CreateBasicEmbed(title, description, userName, userAvatarUrl, DiscordColor.IndianRed);
+ return CreateBasicEmbed(title, string.Empty, userName, userAvatarUrl, DiscordColor.Red, userAvatarUrl, footer, fields);
}
internal static async Task BuildInfoAzzyEmbedAsync(string userName, string userAvatarUrl)
@@ -142,15 +147,15 @@ internal static async Task BuildInfoAzzyEmbedAsync(string userName
ArgumentException.ThrowIfNullOrWhiteSpace(userAvatarUrl, nameof(userAvatarUrl));
string title = CoreStringBuilder.GetEmbedAzzyInfoTitle;
- string botName = BotInfo.GetBotName;
- string botUptime = BotInfo.GetBotUptime;
- string botVersion = BotInfo.GetBotVersion;
- string dotnetVersion = BotInfo.GetDotNetVersion;
- string libVersion = BotInfo.GetDSharpNetVersion.Split('+')[0];
- string commit = await BotInfo.GetBotCommitAsync();
- string compilationDate = await BotInfo.GetBotCompileDateAsync();
- string botEnvironment = BotInfo.GetBotEnvironment;
- string activatedModules = BotInfo.GetActivatedModules();
+ string botName = CoreAzzyStatsGeneral.GetBotName;
+ string botUptime = CoreAzzyStatsGeneral.GetBotUptime();
+ string botVersion = CoreAzzyStatsGeneral.GetBotVersion;
+ string dotnetVersion = CoreAzzyStatsGeneral.GetDotNetVersion;
+ string libVersion = CoreAzzyStatsGeneral.GetDSharpNetVersion.Split('+')[0];
+ string commit = await CoreAzzyStatsGeneral.GetBotCommitAsync();
+ string compilationDate = await CoreAzzyStatsGeneral.GetBotCompileDateAsync();
+ string botEnvironment = CoreAzzyStatsGeneral.GetBotEnvironment;
+ string activatedModules = CoreAzzyStatsGeneral.GetActivatedModules();
Dictionary fields = new()
{
diff --git a/AzzyBot/Modules/Core/CoreFileOperations.cs b/AzzyBot/Modules/Core/CoreFileOperations.cs
index 096b88f3..7e4eb0bd 100644
--- a/AzzyBot/Modules/Core/CoreFileOperations.cs
+++ b/AzzyBot/Modules/Core/CoreFileOperations.cs
@@ -37,6 +37,9 @@ internal static async Task GetFileContentAsync(string fileName, string[]
try
{
+ if (!File.Exists(GetFileNameAndPath(fileName, directory)))
+ throw new FileNotFoundException();
+
return await File.ReadAllTextAsync(GetFileNameAndPath(fileName, directory));
}
catch (DirectoryNotFoundException)
@@ -135,7 +138,9 @@ private static async Task CreateTemplateFileAsync(string fileName, string[
return true;
await File.Create(path).DisposeAsync();
- UpdaterMisc.SetFilePermission(path, "0755");
+
+ if (CoreMisc.CheckIfLinuxOs())
+ UpdaterMisc.SetFilePermission(path, "0755");
if (!File.Exists(path))
throw new FileNotFoundException($"Could not create file: {path}");
diff --git a/AzzyBot/Modules/Core/CoreModule.cs b/AzzyBot/Modules/Core/CoreModule.cs
index 8c965c63..515ef65f 100644
--- a/AzzyBot/Modules/Core/CoreModule.cs
+++ b/AzzyBot/Modules/Core/CoreModule.cs
@@ -41,7 +41,7 @@ protected override void HandleModuleEvent(ModuleEvent evt)
switch (evt.Type)
{
case ModuleEventType.GlobalTimerTick:
- if (BotInfo.GetBotEnvironment == "Development")
+ if (CoreAzzyStatsGeneral.GetBotEnvironment == "Development")
break;
DateTime now = DateTime.Now;
diff --git a/AzzyBot/Program.cs b/AzzyBot/Program.cs
index 6315f216..65ba8619 100644
--- a/AzzyBot/Program.cs
+++ b/AzzyBot/Program.cs
@@ -241,7 +241,6 @@ async Task BotShutdown()
#region Initialize Strings
- BotInfo.SetStartTime();
await StringBuilding.LoadStringsAsync();
#endregion Initialize Strings
diff --git a/AzzyBot/Settings/BaseSettings.cs b/AzzyBot/Settings/BaseSettings.cs
index df271b47..c40eb8b6 100644
--- a/AzzyBot/Settings/BaseSettings.cs
+++ b/AzzyBot/Settings/BaseSettings.cs
@@ -24,7 +24,7 @@ internal abstract class BaseSettings
private static void SetDevConfig()
{
- if (BotInfo.GetBotName != "AzzyBot-Dev")
+ if (CoreAzzyStatsGeneral.GetBotName != "AzzyBot-Dev")
return;
builder.Sources.Clear();
diff --git a/AzzyBot/Strings/Core/CoreStringBuilder.cs b/AzzyBot/Strings/Core/CoreStringBuilder.cs
index 51758d6b..b64814ee 100644
--- a/AzzyBot/Strings/Core/CoreStringBuilder.cs
+++ b/AzzyBot/Strings/Core/CoreStringBuilder.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
@@ -53,34 +54,46 @@ internal static async Task LoadCoreStringsAsync()
internal static string GetEmbedAzzyStatsCpuUsageCore(int counter, double value) => BuildString(BuildString(Model.EmbedAzzyStatsCpuUsageCore, "%COUNTER%", counter), "%VALUE%", value);
internal static string GetEmbedAzzyStatsDiskUsageDesc(double used, double total) => BuildString(BuildString(Model.EmbedAzzyStatsDiskUsageDesc, "%USED%", used), "%TOTAL%", total);
- [SuppressMessage("Roslynator", "RCS1250:Use implicit/explicit object creation", Justification = "Collection Expression are not yet available for Dictionaries.")]
internal static Dictionary GetEmbedAzzyStatsFields(long uptime, int ping, string coreUsage, double oneMinLoad, double fiveMinLoad, double fifteenMinLoad, double memUsage, double azzyMem, double memTotal, string diskUsage)
{
- return new Dictionary()
- {
- [Model.EmbedAzzyStatsSystemUptimeTitle] = new(Model.EmbedAzzyStatsSystemUptimeTitle, BuildString(Model.EmbedAzzyStatsSystemUptimeDesc, "%VALUE%", $""), false),
- [Model.EmbedAzzyStatsPingTitle] = new(Model.EmbedAzzyStatsPingTitle, BuildString(Model.EmbedAzzyStatsPingDesc, "%VALUE%", ping), false),
- [Model.EmbedAzzyStatsCpuUsageTitle] = new(Model.EmbedAzzyStatsCpuUsageTitle, coreUsage, false),
- [Model.EmbedAzzyStats1MinLoadTitle] = new(Model.EmbedAzzyStats1MinLoadTitle, BuildString(Model.EmbedAzzyStats1MinLoadDesc, "%VALUE%", oneMinLoad), true),
- [Model.EmbedAzzyStats5MinLoadTitle] = new(Model.EmbedAzzyStats5MinLoadTitle, BuildString(Model.EmbedAzzyStats5MinLoadDesc, "%VALUE%", fiveMinLoad), true),
- [Model.EmbedAzzyStats15MinLoadTitle] = new(Model.EmbedAzzyStats15MinLoadTitle, BuildString(Model.EmbedAzzyStats15MinLoadDesc, "%VALUE%", fifteenMinLoad), true),
- [Model.EmbedAzzyStatsRamUsageTitle] = new(Model.EmbedAzzyStatsRamUsageTitle, BuildString(BuildString(BuildString(Model.EmbedAzzyStatsRamUsageDesc, "%USED%", memUsage), "%BOT%", azzyMem), "%TOTAL%", memTotal), false),
- [Model.EmbedAzzyStatsDiskUsageTitle] = new(Model.EmbedAzzyStatsDiskUsageTitle, diskUsage, false)
- };
+ Dictionary fields = [];
+
+ if (uptime is not 0)
+ fields.Add(Model.EmbedAzzyStatsSystemUptimeTitle, new(Model.EmbedAzzyStatsSystemUptimeTitle, BuildString(Model.EmbedAzzyStatsSystemUptimeDesc, "%VALUE%", $""), false));
+
+ if (ping is not 0)
+ fields.Add(Model.EmbedAzzyStatsPingTitle, new(Model.EmbedAzzyStatsPingTitle, BuildString(Model.EmbedAzzyStatsPingDesc, "%VALUE%", ping), false));
+
+ if (!string.IsNullOrWhiteSpace(coreUsage))
+ fields.Add(Model.EmbedAzzyStatsCpuUsageTitle, new(Model.EmbedAzzyStatsCpuUsageTitle, coreUsage, false));
+
+ if (oneMinLoad is not 0)
+ fields.Add(Model.EmbedAzzyStats1MinLoadTitle, new(Model.EmbedAzzyStats1MinLoadTitle, BuildString(Model.EmbedAzzyStats1MinLoadDesc, "%VALUE%", oneMinLoad), true));
+
+ if (fiveMinLoad is not 0)
+ fields.Add(Model.EmbedAzzyStats5MinLoadTitle, new(Model.EmbedAzzyStats5MinLoadTitle, BuildString(Model.EmbedAzzyStats5MinLoadDesc, "%VALUE%", fiveMinLoad), true));
+
+ if (fifteenMinLoad is not 0)
+ fields.Add(Model.EmbedAzzyStats15MinLoadTitle, new(Model.EmbedAzzyStats15MinLoadTitle, BuildString(Model.EmbedAzzyStats15MinLoadDesc, "%VALUE%", fifteenMinLoad), true));
+
+ if (memUsage is not 0 && memTotal is not 0)
+ fields.Add(Model.EmbedAzzyStatsRamUsageTitle, new(Model.EmbedAzzyStatsRamUsageTitle, BuildString(BuildString(Model.EmbedAzzyStatsRamUsageDesc, "%USED%", memUsage), "%TOTAL%", memTotal), false));
+
+ if (azzyMem is not 0)
+ fields.Add(Model.EmbedAzzyStatsRamUsageAzzyTitle, new(Model.EmbedAzzyStatsRamUsageAzzyTitle, BuildString(Model.EmbedAzzyStatsRamUsageAzzyDesc, "%BOT%", azzyMem), false));
+
+ if (!string.IsNullOrWhiteSpace(diskUsage))
+ fields.Add(Model.EmbedAzzyStatsDiskUsageTitle, new(Model.EmbedAzzyStatsDiskUsageTitle, diskUsage, false));
+
+ return fields;
}
internal static string GetEmbedAzzyStatsNetworkUsageTitle(string name) => BuildString(Model.EmbedAzzyStatsNetworkUsageTitle, "%NAME%", name);
internal static string GetEmbedAzzyStatsNetworkUsageDesc(double receive, double transmit) => BuildString(BuildString(Model.EmbedAzzyStatsNetworkUsageDesc, "%RECEIVE%", receive), "%TRANSMIT%", transmit);
+ internal static string GetEmbedAzzyStatsMoreStats => Model.EmbedAzzyStatsMoreStats;
#endregion BuildAzzyStatsEmbed
- #region BuildAzzyStatsNotAvailableEmbed
-
- internal static string GetEmbedAzzyStatsNotAvailableTitle => Model.EmbedAzzyStatsNotAvailableTitle;
- internal static string GetEmbedAzzyStatsNotAvailableDesc => Model.EmbedAzzyStatsNotAvailableDesc;
-
- #endregion BuildAzzyStatsNotAvailableEmbed
-
#region BuildInfoAzzyEmbed
internal static string GetEmbedAzzyInfoTitle => Model.EmbedAzzyInfoTitle;
diff --git a/AzzyBot/Strings/Core/CoreStringModel.cs b/AzzyBot/Strings/Core/CoreStringModel.cs
index f5fb5e0a..8bc4b930 100644
--- a/AzzyBot/Strings/Core/CoreStringModel.cs
+++ b/AzzyBot/Strings/Core/CoreStringModel.cs
@@ -36,20 +36,16 @@ internal sealed class CoreStringModel
public string EmbedAzzyStats15MinLoadDesc { get; set; } = string.Empty;
public string EmbedAzzyStatsRamUsageTitle { get; set; } = string.Empty;
public string EmbedAzzyStatsRamUsageDesc { get; set; } = string.Empty;
+ public string EmbedAzzyStatsRamUsageAzzyTitle { get; set; } = string.Empty;
+ public string EmbedAzzyStatsRamUsageAzzyDesc { get; set; } = string.Empty;
public string EmbedAzzyStatsDiskUsageTitle { get; set; } = string.Empty;
public string EmbedAzzyStatsDiskUsageDesc { get; set; } = string.Empty;
public string EmbedAzzyStatsNetworkUsageTitle { get; set; } = string.Empty;
public string EmbedAzzyStatsNetworkUsageDesc { get; set; } = string.Empty;
+ public string EmbedAzzyStatsMoreStats { get; set; } = string.Empty;
#endregion BuildAzzyStatsEmbed
- #region BuildAzzyStatsNotAvailableEmbed
-
- public string EmbedAzzyStatsNotAvailableTitle { get; set; } = string.Empty;
- public string EmbedAzzyStatsNotAvailableDesc { get; set; } = string.Empty;
-
- #endregion BuildAzzyStatsNotAvailableEmbed
-
#region BuildInfoAzzyEmbed
public string EmbedAzzyInfoTitle { get; set; } = string.Empty;
diff --git a/AzzyBot/Updater/UpdaterMisc.cs b/AzzyBot/Updater/UpdaterMisc.cs
index 1a2f95c4..10c404f0 100644
--- a/AzzyBot/Updater/UpdaterMisc.cs
+++ b/AzzyBot/Updater/UpdaterMisc.cs
@@ -22,10 +22,9 @@ internal static void CheckIfDirIsPresent()
internal static void RestartBot()
{
- string updater = (BotInfo.GetBotEnvironment == "Development") ? "Updater-Dev" : "Updater";
ProcessStartInfo startInfo = new()
{
- Arguments = $"-c \"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater", updater)} restart\"",
+ Arguments = $"-c \"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater", "Updater")} restart\"",
FileName = "/bin/bash",
CreateNoWindow = true,
RedirectStandardOutput = true
diff --git a/AzzyBot/Updater/Updates.cs b/AzzyBot/Updater/Updates.cs
index 62fa5fc5..e47fe4cd 100644
--- a/AzzyBot/Updater/Updates.cs
+++ b/AzzyBot/Updater/Updates.cs
@@ -22,8 +22,7 @@ internal static async Task CheckForUpdatesAsync(bool notify)
UpdaterMisc.CheckIfDirIsPresent();
string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater");
- string updater = (BotInfo.GetBotEnvironment == "Development") ? "Updater-Dev" : "Updater";
- string filePath = Path.Combine(basePath, updater);
+ string filePath = Path.Combine(basePath, "Updater");
string versionPath = Path.Combine(basePath, "version.txt");
string version = string.Empty;
@@ -101,9 +100,8 @@ internal static async Task CheckForUpdaterUpdatesAsync()
{
UpdaterMisc.CheckIfDirIsPresent();
- string updater = (BotInfo.GetBotEnvironment == "Development") ? "Updater-Dev.dll" : "Updater.dll";
string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updater");
- string filePath = Path.Combine(basePath, updater);
+ string filePath = Path.Combine(basePath, "Updater.dll");
string settingsPath = Path.Combine(basePath, "appsettings.json");
string text;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9814198..b46541c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,4 +16,8 @@
### Improvements
- Code cleanup
-- CI Updates for better processability
\ No newline at end of file
+- CI Updates for better processability
+
+### Fixes
+- `core info azzy` and `core ping azzy` can now be used on windows too
+ - `core ping azzy` has way less information than on linux because of the insufficient rights of a regular user account
\ No newline at end of file