From 4f2ee8ab745689d5231e494bf495a0df3621d19e Mon Sep 17 00:00:00 2001 From: Xubiod Date: Sat, 16 Dec 2023 23:41:46 -0500 Subject: [PATCH] more automated rider --- xubot/src/Util.cs | 54 +++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/xubot/src/Util.cs b/xubot/src/Util.cs index 20f79f6..e88bf55 100644 --- a/xubot/src/Util.cs +++ b/xubot/src/Util.cs @@ -41,21 +41,22 @@ public static async Task BuildErrorAsync(IResult result, CommandContext context) var error = result.Error; if (error == null) return; - embed.Fields = new List - { - new() + embed.Fields = + [ + new EmbedFieldBuilder { Name = "Error Reason", Value = "```" + result.ErrorReason + "```", IsInline = false }, - new() + + new EmbedFieldBuilder { Name = "What it is", Value = "```" + error.GetType() + "```", IsInline = false } - }; + ]; await context.Channel.SendMessageAsync("", false, embed.Build()); } @@ -64,15 +65,15 @@ public static async Task BuildErrorAsync(CommandError err, CommandContext contex { EmbedBuilder embed = GetErrorBoilerplate(); - embed.Fields = new List - { - new() + embed.Fields = + [ + new EmbedFieldBuilder { Name = "CommandError Error", Value = "```" + err + "```", IsInline = false } - }; + ]; await context.Channel.SendMessageAsync("", false, embed.Build()); } @@ -102,33 +103,36 @@ public static async Task BuildErrorAsync(Exception exp, ICommandContext context) EmbedBuilder embed = GetErrorBoilerplate(); embed.Description = $"It's a ***{exp.GetType()}***."; - embed.Fields = new List - { - new() + embed.Fields = + [ + new EmbedFieldBuilder { Name = "Source", Value = $"```{exp.Source}```", IsInline = false }, - new() + + new EmbedFieldBuilder { Name = "Message", Value = $"```{exp.Message}```", IsInline = false }, - new() + + new EmbedFieldBuilder { Name = "Target Site", Value = $"```{exp.TargetSite}```", IsInline = false }, - new() + + new EmbedFieldBuilder { Name = "Stack Trace", Value = $"```{stack}```", IsInline = false } - }; + ]; await context.Channel.SendMessageAsync("", false, embed.Build()); if (stacktraceToFile && Global.Default.SendBigStacktraceOnError) @@ -140,15 +144,15 @@ public static async Task BuildErrorAsync(Exception exp, ICommandContext context) public static async Task BuildErrorAsync(string problem, ICommandContext context) { EmbedBuilder embed = GetErrorBoilerplate(); - embed.Fields = new List - { - new() + embed.Fields = + [ + new EmbedFieldBuilder { Name = "Details", Value = "```" + problem + "```", IsInline = false } - }; + ]; await context.Channel.SendMessageAsync("", false, embed.Build()); } @@ -158,15 +162,15 @@ public static async Task BuildErrorAsync(object problem, ICommandContext context EmbedBuilder embed = GetErrorBoilerplate(); embed.Description = "It's a dedicated ***" + problem.GetType() + "*** issue."; - embed.Fields = new List - { - new() + embed.Fields = + [ + new EmbedFieldBuilder { Name = "Details", Value = $"```{problem}```", IsInline = false } - }; + ]; await context.Channel.SendMessageAsync("", false, embed.Build()); } @@ -182,7 +186,7 @@ public static class Json public class Entry(string filename, dynamic contents) { public string Filename { get; } = filename; - public dynamic Contents { get; set; } = contents; + public dynamic Contents { get; } = contents; } public static async void ProcessFile(string key, string jsonFile)