mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
fix some misc stuff and add more diagnostics
This commit is contained in:
@@ -22,8 +22,10 @@ internal static class BotStatus
|
||||
}
|
||||
.AddField("Current Uptime", Config.Uptime.Elapsed.AsShortTimespan(), true)
|
||||
.AddField("Discord Latency", $"{latency.TotalMilliseconds:0.0} ms", true);
|
||||
if (!string.IsNullOrEmpty(Config.AzureComputerVisionKey))
|
||||
if (Config.AzureComputerVisionKey is {Length: >0})
|
||||
embed.AddField("Max OCR Queue", MediaScreenshotMonitor.MaxQueueLength.ToString(), true);
|
||||
else
|
||||
embed.AddField("Max OCR Queue", "-", true);
|
||||
var osInfo = RuntimeInformation.OSDescription;
|
||||
if (Environment.OSVersion.Platform is PlatformID.Unix or PlatformID.MacOSX)
|
||||
osInfo = RuntimeInformation.RuntimeIdentifier;
|
||||
|
||||
@@ -66,6 +66,7 @@ internal static class Explain
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
explainMsg.AddFile(result.explanation.AttachmentFilename!, memStream);
|
||||
await ctx.RespondAsync(explainMsg).ConfigureAwait(false);
|
||||
StatsStorage.IncExplainStat(term);
|
||||
}
|
||||
|
||||
[Command("add"), RequiresBotModRole]
|
||||
|
||||
@@ -21,7 +21,7 @@ internal static class MemoryCacheExtensions
|
||||
var coherentState = stateField?.GetValue(memoryCache);
|
||||
if (coherentState is null)
|
||||
{
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed");
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {nameof(coherentState)}");
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ internal static class MemoryCacheExtensions
|
||||
.FirstOrDefault(fi => fi.Name == "_nonStringEntries");
|
||||
if (stringField is null || nonStringField is null)
|
||||
{
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed");
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {nameof(stringField)}");
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ internal static class MemoryCacheExtensions
|
||||
var coherentState = stateField?.GetValue(memoryCache);
|
||||
if (coherentState is null)
|
||||
{
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed");
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {nameof(coherentState)}");
|
||||
return new();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ internal static class MemoryCacheExtensions
|
||||
var cacheEntries = (IDictionary?)field?.GetValue(coherentState);
|
||||
if (cacheEntries is null)
|
||||
{
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed");
|
||||
Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {cacheEntries}");
|
||||
return new(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,13 @@ public class MemoryCacheExtensionTests
|
||||
|
||||
const string testVal = "vale13";
|
||||
cache.Set(13, testVal);
|
||||
cache.Set("bob", 69);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(cache.TryGetValue(13, out string? expectedVal), Is.True);
|
||||
Assert.That(expectedVal, Is.EqualTo(testVal));
|
||||
Assert.That(cache.TryGetValue("bob", out int? expectedValInt), Is.True);
|
||||
Assert.That(expectedValInt, Is.EqualTo(69));
|
||||
}
|
||||
);
|
||||
Assert.That(cache.GetCacheKeys<int>(), Has.Count.EqualTo(1));
|
||||
@@ -32,6 +35,8 @@ public class MemoryCacheExtensionTests
|
||||
Assert.That(cache.GetCacheKeys<int>(), Is.Empty);
|
||||
|
||||
cache.Set(13, "val13");
|
||||
cache.Set("bob", 69);
|
||||
Assert.That(cache.GetCacheKeys<int>(), Has.Count.EqualTo(1));
|
||||
Assert.That(cache.GetCacheKeys<string>(), Has.Count.EqualTo(1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user