- Added MissingMethodException to common errors

- Added jump to message feature to log analysis
- Fixed notes not being allowed to be longer than 256 characters.
This commit is contained in:
pan.codes 2024-04-19 19:47:56 +02:00
parent 7f08d72ef8
commit c931718ce5
6 changed files with 44 additions and 30 deletions

View file

@ -24,7 +24,7 @@ namespace SMSModLogOutputAnalyzer.Data
} }
public static void Save() public static void Save()
{ {
SerializerXML.SerializeToFile(Instance, "Config.xml"); try { SerializerXML.SerializeToFile(Instance, "Config.xml"); } catch (Exception e) { Console.WriteLine(e); }
} }
public static Config Instance { get; set; } public static Config Instance { get; set; }
} }

View file

@ -17,7 +17,7 @@ namespace SMSModLogOutputAnalyzer.Data
{ {
var unix = ((DateTimeOffset)CreationTime).ToUnixTimeSeconds(); var unix = ((DateTimeOffset)CreationTime).ToUnixTimeSeconds();
// "Note " + Id, "`" + Text + "`\nCreated by <@" + CreatorID + "> at <t:" + unix + ":f>" // "Note " + Id, "`" + Text + "`\nCreated by <@" + CreatorID + "> at <t:" + unix + ":f>"
return new EmbedFieldBuilder().WithName(Text).WithValue("ID: `" + Id + "`\nCreated by <@" + CreatorID + "> at <t:" + unix + ":f>"); return new EmbedFieldBuilder().WithName("\u200b").WithValue("**"+Text+"**\nID: `" + Id + "`\nCreated by <@" + CreatorID + "> at <t:" + unix + ":f>");
} }
} }
} }

View file

@ -31,7 +31,7 @@ namespace SMSModLogOutputAnalyzer.Data
public void Save() public void Save()
{ {
SerializerXML.SerializeToFile(this, "NotesData.xml"); try { SerializerXML.SerializeToFile(this, "NotesData.xml"); } catch (Exception e) { Console.WriteLine(e); }
} }
public static NotesDataObject Load() public static NotesDataObject Load()
{ {

View file

@ -13,7 +13,7 @@ namespace SMSModLogOutputAnalyzer.Data
{ {
public void Save() public void Save()
{ {
SerializerXML.SerializeToFile(this, "RoleButtons.xml"); try { SerializerXML.SerializeToFile(this, "RoleButtons.xml"); } catch (Exception e) { Console.WriteLine(e); }
} }
public static RoleButtonsDataObject Load() public static RoleButtonsDataObject Load()
{ {

View file

@ -40,7 +40,7 @@ namespace SMSModLogOutputAnalyzer.Modules
{ {
if(message.Attachments.Count > 0) if(message.Attachments.Count > 0)
{ {
await Upload((Attachment)message.Attachments.First()); await Analyze((Attachment)message.Attachments.First(), message);
} else } else
{ {
await RespondAsync(embed: new EmbedBuilder().WithDescription("Message has no attachment.").WithDefaults().Build(), ephemeral: true); await RespondAsync(embed: new EmbedBuilder().WithDescription("Message has no attachment.").WithDefaults().Build(), ephemeral: true);
@ -48,6 +48,10 @@ namespace SMSModLogOutputAnalyzer.Modules
} }
[SlashCommand("upload", "Upload a LogOutput.log file for analysis.")] [SlashCommand("upload", "Upload a LogOutput.log file for analysis.")]
public async Task Upload([Summary(description: "Please upload your LogOutput.log file. It is found inside the BepInEx folder in your game directory.")] Attachment file) public async Task Upload([Summary(description: "Please upload your LogOutput.log file. It is found inside the BepInEx folder in your game directory.")] Attachment file)
{
await Analyze(file);
}
public async Task Analyze(Attachment file, IMessage logmessage = null)
{ {
try try
{ {
@ -73,10 +77,13 @@ namespace SMSModLogOutputAnalyzer.Modules
"[Info : BepInEx] Loading [", "[Info : BepInEx] Loading [",
"[Message:MelonLoader] Assembly: ", "[Message:MelonLoader] Assembly: ",
"[Info : Unity Log] System.EntryPointNotFoundException: SteamAPI_SteamInput_v001", "[Info : Unity Log] System.EntryPointNotFoundException: SteamAPI_SteamInput_v001",
"[Message: File Tree] "); "[Message: File Tree] ",
"[Error : Unity Log] MissingMethodException");
Log("Initial analysis complete."); Log("Initial analysis complete.");
if(logmessage != null) values[":envelope_with_arrow: Jump to Message"] = new List<string> { logmessage.GetJumpUrl() };
values[":page_facing_up: Game Version"] = new List<string> { lines["[Message:MelonLoader] Game Version: "][0].Line }; values[":page_facing_up: Game Version"] = new List<string> { lines["[Message:MelonLoader] Game Version: "][0].Line };
values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List<string> { lines["[Message:MelonLoader] Unity Version: "][0].Line }; values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List<string> { lines["[Message:MelonLoader] Unity Version: "][0].Line };
values[":tools: BepInEx Version"] = new List<string> { lines["[Message: BepInEx] BepInEx "][0].Line.Split(" - ")[0] }; values[":tools: BepInEx Version"] = new List<string> { lines["[Message: BepInEx] BepInEx "][0].Line.Split(" - ")[0] };
@ -100,6 +107,7 @@ namespace SMSModLogOutputAnalyzer.Modules
part = new(); part = new();
if (lines["[Info : Unity Log] System.EntryPointNotFoundException: SteamAPI_SteamInput_v001"].Count > 0) part.Add(":x: Steam Entry Point not found"); if (lines["[Info : Unity Log] System.EntryPointNotFoundException: SteamAPI_SteamInput_v001"].Count > 0) part.Add(":x: Steam Entry Point not found");
if (lines["[Error : Unity Log] MissingMethodException"].Count > 0) part.Add(":x: MissingMethodException" + lines["[Error : Unity Log] MissingMethodException"][0].Line);
values[":loudspeaker: Common Errors"] = part; values[":loudspeaker: Common Errors"] = part;
part = new(); part = new();

View file

@ -12,6 +12,8 @@ namespace SMSModLogOutputAnalyzer.Modules
[SlashCommand("view", "View notes that have been added to a user.")] [SlashCommand("view", "View notes that have been added to a user.")]
[RequireUserPermission(GuildPermission.ManageRoles)] [RequireUserPermission(GuildPermission.ManageRoles)]
public async Task View(IUser user, [Summary(description: "How many notes to skip (used for pagination)")] int offset = 0) public async Task View(IUser user, [Summary(description: "How many notes to skip (used for pagination)")] int offset = 0)
{
try
{ {
EmbedBuilder embedBuilder = new EmbedBuilder(); EmbedBuilder embedBuilder = new EmbedBuilder();
@ -42,6 +44,10 @@ namespace SMSModLogOutputAnalyzer.Modules
{ {
await RespondAsync(embed: embed, ephemeral: true); await RespondAsync(embed: embed, ephemeral: true);
} }
} catch(Exception e)
{
Console.WriteLine(e);
}
} }
[SlashCommand("add", "Add a note to a user.")] [SlashCommand("add", "Add a note to a user.")]
[RequireUserPermission(GuildPermission.ManageRoles)] [RequireUserPermission(GuildPermission.ManageRoles)]