Skip to content

Commit

Permalink
more automated rider
Browse files Browse the repository at this point in the history
  • Loading branch information
xubiod committed Dec 17, 2023
1 parent acf34ff commit 4f2ee8a
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions xubot/src/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmbedFieldBuilder>
{
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());
}
Expand All @@ -64,15 +65,15 @@ public static async Task BuildErrorAsync(CommandError err, CommandContext contex
{
EmbedBuilder embed = GetErrorBoilerplate();

embed.Fields = new List<EmbedFieldBuilder>
{
new()
embed.Fields =
[
new EmbedFieldBuilder
{
Name = "CommandError Error",
Value = "```" + err + "```",
IsInline = false
}
};
];

await context.Channel.SendMessageAsync("", false, embed.Build());
}
Expand Down Expand Up @@ -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<EmbedFieldBuilder>
{
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)
Expand All @@ -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<EmbedFieldBuilder>
{
new()
embed.Fields =
[
new EmbedFieldBuilder
{
Name = "Details",
Value = "```" + problem + "```",
IsInline = false
}
};
];

await context.Channel.SendMessageAsync("", false, embed.Build());
}
Expand All @@ -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<EmbedFieldBuilder>
{
new()
embed.Fields =
[
new EmbedFieldBuilder
{
Name = "Details",
Value = $"```{problem}```",
IsInline = false
}
};
];

await context.Channel.SendMessageAsync("", false, embed.Build());
}
Expand All @@ -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)
Expand Down

0 comments on commit 4f2ee8a

Please sign in to comment.