/// <summary> /// Adds a new verbal log entry to the file /// </summary> /// <param name="verbalEntry">VerbalModlogEntry instance to add to file</param> public static void AddVerbalModlogEntry(this DiscordMember member, VerbalModlogEntry verbalEntry) { UserModlog user = Deserialize(member.Username, member.Id); user.VerbalLog.Add(verbalEntry); user.VerbalLogEntryCount++; Serialize(user, member.Id); }
/// <summary> /// Attempts to add a verballog entry to a specific user. Returns true if successful. /// </summary> public static Task <Boolean> TryAddVerballogEntry(this DiscordUser user, VerbalModlogEntry entry) { if (user == null) { throw new ArgumentException("Could not add modlog entry to nonexistent user", nameof(user)); } try { (user as DiscordMember).AddVerbalModlogEntry(entry); return(Task.FromResult(true)); } catch (Exception e) { Console.WriteLine($"{e}: {e.Message}\n{e.StackTrace}"); return(Task.FromResult(false)); } }