From c931718ce59b5ec8f65cff7bf931610fd08cbef8 Mon Sep 17 00:00:00 2001 From: Jonathan Riedel Date: Fri, 19 Apr 2024 19:47:56 +0200 Subject: [PATCH] - Added MissingMethodException to common errors - Added jump to message feature to log analysis - Fixed notes not being allowed to be longer than 256 characters. --- SMSModLogOutputAnalyzer/Data/Config.cs | 2 +- .../Data/NotesDataObject.Note.cs | 2 +- .../Data/NotesDataObject.cs | 2 +- .../Data/RoleButtonsDataObject.cs | 2 +- .../Modules/LogAnalyze/LogAnalyzeModule.cs | 12 ++++- .../Modules/Notes/NotesModule.Commands.cs | 54 ++++++++++--------- 6 files changed, 44 insertions(+), 30 deletions(-) diff --git a/SMSModLogOutputAnalyzer/Data/Config.cs b/SMSModLogOutputAnalyzer/Data/Config.cs index 6c00363..7335184 100644 --- a/SMSModLogOutputAnalyzer/Data/Config.cs +++ b/SMSModLogOutputAnalyzer/Data/Config.cs @@ -24,7 +24,7 @@ namespace SMSModLogOutputAnalyzer.Data } 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; } } diff --git a/SMSModLogOutputAnalyzer/Data/NotesDataObject.Note.cs b/SMSModLogOutputAnalyzer/Data/NotesDataObject.Note.cs index 0b70f40..f7b7e74 100644 --- a/SMSModLogOutputAnalyzer/Data/NotesDataObject.Note.cs +++ b/SMSModLogOutputAnalyzer/Data/NotesDataObject.Note.cs @@ -17,7 +17,7 @@ namespace SMSModLogOutputAnalyzer.Data { var unix = ((DateTimeOffset)CreationTime).ToUnixTimeSeconds(); // "Note " + Id, "`" + Text + "`\nCreated by <@" + CreatorID + "> at " - return new EmbedFieldBuilder().WithName(Text).WithValue("ID: `" + Id + "`\nCreated by <@" + CreatorID + "> at "); + return new EmbedFieldBuilder().WithName("\u200b").WithValue("**"+Text+"**\nID: `" + Id + "`\nCreated by <@" + CreatorID + "> at "); } } } diff --git a/SMSModLogOutputAnalyzer/Data/NotesDataObject.cs b/SMSModLogOutputAnalyzer/Data/NotesDataObject.cs index d88cb2b..b02ca5e 100644 --- a/SMSModLogOutputAnalyzer/Data/NotesDataObject.cs +++ b/SMSModLogOutputAnalyzer/Data/NotesDataObject.cs @@ -31,7 +31,7 @@ namespace SMSModLogOutputAnalyzer.Data public void Save() { - SerializerXML.SerializeToFile(this, "NotesData.xml"); + try { SerializerXML.SerializeToFile(this, "NotesData.xml"); } catch (Exception e) { Console.WriteLine(e); } } public static NotesDataObject Load() { diff --git a/SMSModLogOutputAnalyzer/Data/RoleButtonsDataObject.cs b/SMSModLogOutputAnalyzer/Data/RoleButtonsDataObject.cs index 72f3fde..7cae9d7 100644 --- a/SMSModLogOutputAnalyzer/Data/RoleButtonsDataObject.cs +++ b/SMSModLogOutputAnalyzer/Data/RoleButtonsDataObject.cs @@ -13,7 +13,7 @@ namespace SMSModLogOutputAnalyzer.Data { public void Save() { - SerializerXML.SerializeToFile(this, "RoleButtons.xml"); + try { SerializerXML.SerializeToFile(this, "RoleButtons.xml"); } catch (Exception e) { Console.WriteLine(e); } } public static RoleButtonsDataObject Load() { diff --git a/SMSModLogOutputAnalyzer/Modules/LogAnalyze/LogAnalyzeModule.cs b/SMSModLogOutputAnalyzer/Modules/LogAnalyze/LogAnalyzeModule.cs index df4b4b4..58d41b3 100644 --- a/SMSModLogOutputAnalyzer/Modules/LogAnalyze/LogAnalyzeModule.cs +++ b/SMSModLogOutputAnalyzer/Modules/LogAnalyze/LogAnalyzeModule.cs @@ -40,7 +40,7 @@ namespace SMSModLogOutputAnalyzer.Modules { if(message.Attachments.Count > 0) { - await Upload((Attachment)message.Attachments.First()); + await Analyze((Attachment)message.Attachments.First(), message); } else { 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.")] 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 { @@ -73,10 +77,13 @@ namespace SMSModLogOutputAnalyzer.Modules "[Info : BepInEx] Loading [", "[Message:MelonLoader] Assembly: ", "[Info : Unity Log] System.EntryPointNotFoundException: SteamAPI_SteamInput_v001", - "[Message: File Tree] "); + "[Message: File Tree] ", + "[Error : Unity Log] MissingMethodException"); Log("Initial analysis complete."); + if(logmessage != null) values[":envelope_with_arrow: Jump to Message"] = new List { logmessage.GetJumpUrl() }; + values[":page_facing_up: Game Version"] = new List { lines["[Message:MelonLoader] Game Version: "][0].Line }; values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List { lines["[Message:MelonLoader] Unity Version: "][0].Line }; values[":tools: BepInEx Version"] = new List { lines["[Message: BepInEx] BepInEx "][0].Line.Split(" - ")[0] }; @@ -100,6 +107,7 @@ namespace SMSModLogOutputAnalyzer.Modules part = new(); 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; part = new(); diff --git a/SMSModLogOutputAnalyzer/Modules/Notes/NotesModule.Commands.cs b/SMSModLogOutputAnalyzer/Modules/Notes/NotesModule.Commands.cs index 409cdaf..7672ea1 100644 --- a/SMSModLogOutputAnalyzer/Modules/Notes/NotesModule.Commands.cs +++ b/SMSModLogOutputAnalyzer/Modules/Notes/NotesModule.Commands.cs @@ -13,34 +13,40 @@ namespace SMSModLogOutputAnalyzer.Modules [RequireUserPermission(GuildPermission.ManageRoles)] public async Task View(IUser user, [Summary(description: "How many notes to skip (used for pagination)")] int offset = 0) { - EmbedBuilder embedBuilder = new EmbedBuilder(); - - var notes = Data[user].Notes.Skip(offset).Take(25).ToArray(); - bool addNextPageButton = Data[user].Notes.Count > offset + 25; - if (notes.Length == 0) + try { - await RespondAsync(embed: new EmbedBuilder().WithDefaults().WithDescription("No " + (offset > 0 ? "more " : "") + "notes have been added to this user.").Build(), ephemeral: true); - return; - } + EmbedBuilder embedBuilder = new EmbedBuilder(); - embedBuilder.WithAuthor(user); - embedBuilder.WithDefaults(); + var notes = Data[user].Notes.Skip(offset).Take(25).ToArray(); + bool addNextPageButton = Data[user].Notes.Count > offset + 25; + if (notes.Length == 0) + { + await RespondAsync(embed: new EmbedBuilder().WithDefaults().WithDescription("No " + (offset > 0 ? "more " : "") + "notes have been added to this user.").Build(), ephemeral: true); + return; + } - foreach (var note in notes) + embedBuilder.WithAuthor(user); + embedBuilder.WithDefaults(); + + foreach (var note in notes) + { + embedBuilder.AddField(note.ToField()); + } + + var embed = embedBuilder.Build(); + var button = new ComponentBuilder().WithButton("Next Page", "view_notes:" + user.Id + ":" + (offset + 25)).Build(); + + if (addNextPageButton) + { + await RespondAsync(embed: embed, components: button, ephemeral: true); + } + else + { + await RespondAsync(embed: embed, ephemeral: true); + } + } catch(Exception e) { - embedBuilder.AddField(note.ToField()); - } - - var embed = embedBuilder.Build(); - var button = new ComponentBuilder().WithButton("Next Page", "view_notes:" + user.Id + ":" + (offset + 25)).Build(); - - if (addNextPageButton) - { - await RespondAsync(embed: embed, components: button, ephemeral: true); - } - else - { - await RespondAsync(embed: embed, ephemeral: true); + Console.WriteLine(e); } } [SlashCommand("add", "Add a note to a user.")]